Advertisement
Guest User

Getaways API v2

a guest
May 21st, 2018
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.30 KB | None | 0 0
  1. //Two arrays are created as though two leads were being sent
  2. //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
  3. //All fields are optional, and a lead will be saved as long as one lead comes through
  4. $lead1 = [
  5. "firstName" => "Grant",
  6. "lastName" => "Imahara",
  7. "address" => "123 Pine Drive",
  8. "address2" => "",
  9. "city" => "Greenbay",
  10. "stateProvince" => "New Mexico",
  11. "postalCode" => "39304",
  12. "sex" => "Male",
  13. "emailAddress" => "email@gmail.com",
  14. "dateOfBirth" => "1/2/1980",
  15. "mobileTelephone" => "1234567890",
  16. "holidaysPerYear" => "1-3 holidays per year",
  17. "subId" => "39823okd",
  18. "ipAddress" => "192.168.1.1",
  19. "timestamp" => "2018-2-3 08:09:10"
  20. ];
  21. $lead2 = [
  22. "firstName" => "June",
  23. "lastName" => "Bug",
  24. "address" => "321 Deciduous Loop",
  25. "address2" => "",
  26. "city" => "Tacoma",
  27. "stateProvince" => "Washington",
  28. "postalCode" => "32234",
  29. "sex" => "Female",
  30. "emailAddress" => "able@bodied.com",
  31. "dateOfBirth" => "",
  32. "mobileTelephone" => "293029893",
  33. "holidaysPerYear" => "2-4 holidays per year",
  34. "subId" => "0wodkf3",
  35. "ipAddress" => "192.168.1.1",
  36. "timestamp" => "2018-2-3 08:09:10"
  37. ];
  38. //The leads are added to the array that houses all leads sent
  39. $leads[] = $lead1;
  40. $leads[] = $lead2;
  41.  
  42. //An example of using cURL to send the request
  43. $ch = curl_init();
  44. //Set the URL
  45. curl_setopt($ch,CURLOPT_URL, 'https://getaways.thevacationtimes.com/api/v2/insert');
  46. //Set the Authorization Header
  47. curl_setopt($ch, CURLOPT_HTTPHEADER, array("X-AUTH-TOKEN: externalapiuser:6X64pH7KweCK6c9t"));
  48. //Set the type of request to POST
  49. curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
  50. //Set the fields being set encoded into a string using http_build_query
  51. curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($leads));
  52. //Execute
  53. $result = curl_exec($ch);
  54. curl_close($ch);
  55. //Result should show success if successful
  56. echo '<pre>';
  57. print_r($result);
  58. echo '</pre>';
  59. return true;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement