Advertisement
sparkweb

FoxyShop: SalesForce Integration

Dec 9th, 2011
767
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.31 KB | None | 0 0
  1. //SalesForce Integation
  2. //Inserts New Lead Into Your Salesforce account
  3.  
  4. $oid = 'XXXXXXXXXXXXX';
  5. $leadsource = 'weborder';
  6.  
  7. $fields = "oid=$oid";
  8. $fields .= "&first_name=" . $customer_first_name;
  9. $fields .= "&last_name=" . $customer_last_name;
  10. $fields .= "&email=" . $customer_email;
  11. $fields .= "&street=" . $customer_address1;
  12. $fields .= "&city=" . $customer_city;
  13. $fields .= "&state=" . $customer_state;
  14. $fields .= "&zip=" . $customer_postal_code;
  15. $fields .= "&country=" . $customer_country;
  16. $fields .= "&company=" . $customer_company;
  17. $fields .= "&phone=" . $customer_phone;
  18. $fields .= "&lead_source=" . $leadsource;
  19. $fields .= "&description=" . urlencode("Order " . $transaction_id);
  20.  
  21. $url = "https://www.salesforce.com/servlet/servlet.WebToLead";
  22. $ch = curl_init();
  23. curl_setopt($ch, CURLOPT_URL,$url);
  24. curl_setopt($ch, CURLOPT_FAILONERROR, 1);
  25. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
  26. curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
  27. curl_setopt($ch, CURLOPT_TIMEOUT, 0);
  28. curl_setopt($ch, CURLOPT_POST, 1);
  29. curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
  30.  
  31. curl_setopt($ch, CURLOPT_FAILONERROR, 0);
  32. curl_setopt($ch, CURLOPT_VERBOSE, 1);
  33. curl_setopt($ch, CURLOPT_HEADER, 1);
  34. curl_setopt($ch, CURLOPT_COOKIEFILE, 1);
  35. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
  36.  
  37. $result = curl_exec($ch);
  38. curl_close($ch);
  39.  
  40.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement