Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Two arrays are created as though two leads were being sent
- //If sending one lead, it would still be sent as if more than one lead was coming through (so it would be as the second dimension of //the "leads" array
- //All fields are optional, and a lead will be saved as long as one lead comes through
- $lead1 = [
- "firstName" => "Grant",
- "lastName" => "Imahara",
- "address" => "123 Pine Drive",
- "address2" => "",
- "city" => "Greenbay",
- "stateProvince" => "New Mexico",
- "postalCode" => "39304",
- "sex" => "Male",
- "emailAddress" => "email@gmail.com",
- "dateOfBirth" => "1/2/1980",
- "mobileTelephone" => "1234567890",
- "holidaysPerYear" => "1-3 holidays per year",
- "subId" => "39823okd",
- "ipAddress" => "192.168.1.1",
- "timestamp" => "2018-2-3 08:09:10"
- ];
- $lead2 = [
- "firstName" => "June",
- "lastName" => "Bug",
- "address" => "321 Deciduous Loop",
- "address2" => "",
- "city" => "Tacoma",
- "stateProvince" => "Washington",
- "postalCode" => "32234",
- "sex" => "Female",
- "emailAddress" => "able@bodied.com",
- "dateOfBirth" => "",
- "mobileTelephone" => "293029893",
- "holidaysPerYear" => "2-4 holidays per year",
- "subId" => "0wodkf3",
- "ipAddress" => "192.168.1.1",
- "timestamp" => "2018-2-3 08:09:10"
- ];
- //The leads are added to the array that houses all leads sent
- $leads[] = $lead1;
- $leads[] = $lead2;
- //An example of using cURL to send the request
- $ch = curl_init();
- //Set the URL
- curl_setopt($ch,CURLOPT_URL, 'https://getaways.thevacationtimes.com/api/v2/insert');
- //Set the Authorization Header
- curl_setopt($ch, CURLOPT_HTTPHEADER, array("X-AUTH-TOKEN: externalapiuser:6X64pH7KweCK6c9t"));
- //Set the type of request to POST
- curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
- //Set the fields being set encoded into a string using http_build_query
- curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($leads));
- //Execute
- $result = curl_exec($ch);
- curl_close($ch);
- //Result should show success if successful
- echo '<pre>';
- print_r($result);
- echo '</pre>';
- return true;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement