‘lastName’ => urlencode($_POST[‘lastName’]),
‘jobTitle’ => urlencode($_POST[‘jobTitle’]),
‘companyName’ => urlencode($_POST[‘companyName’]),
‘description’ => urlencode($_POST[‘description’]),
);
//These are some mandatory values that won’t come from the web form. You can hard-code this, or apply some logic.
// An example would be to change the assignee of a lead, based on the address submitted in the form, so you can distribute leads based on region.
// Click this link to learn how to locate these IDs using your Apptivo account: https://github.com/Apptivo/phplib/wiki/Locating-ID-Numbers-&-Other-Data
$lead_data[‘assigneeObjectRefId’] = ‘18767’;
$lead_data[‘assigneeObjectRefName’] = urlencode(‘Kenny Clark’);
$lead_data[‘referredById’] = ‘18767’;
$lead_data[‘referredByName’] = urlencode(‘Kenny Clark’);
$lead_data[‘leadStatus’] = ‘6826705’;
$lead_data[‘leadStatusMeaning’] = ‘New’;
$lead_data[‘leadSource’] = ‘6827230’;
$lead_data[‘leadSourceMeaning’] = ‘Other’;
$lead_data[‘leadRank’] = ‘6826692’;
$lead_data[‘leadRankMeaning’] = ‘High’;
//Now we’ll build Arrays for each type of grouped data: phone numbers, emails, addresses, and custom fields
//Phone Fields
$phone_numbers = Array(
Array(
‘phoneType’ => $_POST[‘phone_type_1’],
‘phoneNumber’ => $_POST[‘phone_number_1’]
),
Array(
‘phoneType’ => $_POST[‘phone_type_2’],
‘phoneNumber’ => $_POST[‘phone_number_2′]
)
);
//Email Fields
$emails = Array(
Array(
’emailType’ => $_POST[’email_type_1′],
’emailAddress’ => $_POST[’email_address_1′]
),
Array(
’emailType’ => $_POST[’email_type_2′],
’emailAddress’ => $_POST[’email_address_2′]
)
);
//Address Fields
$state_arr = explode(‘,’, $_POST[‘address_state’]); //Address State is a comma separated value with [State ID, State Name]
$addresses = Array (
Array (
‘addressTypeCode’ => 1,
‘addressType’ => urlencode(‘Billing Address’),
‘addressLine1’ => urlencode($_POST[‘address_1’]),
‘addressLine2’ => urlencode($_POST[‘address_2’]),
‘city’ => urlencode($_POST[‘address_city’]),
‘stateCode’ => $state_arr[0],
‘state’ => urlencode($state_arr[1]),
‘zipCode’ => $_POST[‘address_zip’],
‘countryId’ => 176,
‘countryName’ => urlencode(‘United States’)
),
//Hard-coding to shipping address as well, for an example of multi-address usage
Array (
‘addressTypeCode’ => 1,
‘addressType’ => urlencode(‘Shipping Address’),
‘addressLine1’ => urlencode($_POST[‘address_1’]),
‘addressLine2’ => urlencode($_POST[‘address_2’]),
‘city’ => urlencode($_POST[‘address_city’]),
‘stateCode’ => $state_arr[0],
‘state’ => urlencode($state_arr[1]),
‘zipCode’ => $_POST[‘address_zip’],
‘countryId’ => 176,
‘countryName’ => urlencode(‘United States’)
)
);
//Custom Fields. The attribute IDs need to be hard-coded. Learn how to find these values here: https://github.com/Apptivo/phplib/wiki/Locating-ID-Numbers-&-Other-Data
$custom_attributes = Array(
Array (
‘customAttributeType’ => ‘select’,
‘id’ => ‘attr_11756_8834_select_6950d1d89a0a96715e5a350129e90346’,
‘customAttributeValue’ => $_POST[‘lead_isp’] // This is the value passed in from the web form
),
Array (
‘customAttributeType’ => ‘input’,
‘id’ => ‘attribute_input_1390553045821_8872’,
‘customAttributeValue’ => $_POST[‘lead_speed’] // This is the value passed in from the web form
),
Array (
‘customAttributeType’ => ‘textarea’,
‘id’ => ‘attribute_textarea_1414645553485_2116’,
‘customAttributeValue’ => urlencode($_POST[‘special_instructions’]) // This is the value passed in from the web form
)
);
//Finally, we call the method to create a lead. Returns a success/failure message
$form_message = $apptivo->create_lead($lead_data, $phone_numbers, $addresses, $emails, $custom_attributes);
}else{
$form_message = ‘Please complete the form below to proceed’;
}
?>
/* START Web Form HTML*/
echo(‘
‘);
/* END Web Form HTML*/
?>