Last active
February 10, 2023 14:44
-
-
Save pedroagabreu/1908892061fcb2b2f3c6 to your computer and use it in GitHub Desktop.
Salesforce web to lead via php-curl.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$sfurl = 'https://webto.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8'; | |
$sffields = array( | |
'oid' => 'someoid', | |
'lead_source' => 'my website', | |
'last_name' => urlencode($_POST['name']), | |
'company' => urlencode($_POST['organization']), | |
'email' => urlencode($_POST['email']), | |
'phone' => urlencode($_POST['phone']), | |
); | |
foreach($sffields as $key=>$value) { $fieldstring .= $key.'='.$value.'&'; } | |
rtrim($fieldstring, '&'); | |
$ch = curl_init(); | |
curl_setopt($ch, CURLOPT_URL, $sfurl); | |
curl_setopt($ch, CURLOPT_POST, count($sffields)); | |
curl_setopt($ch, CURLOPT_POSTFIELDS, $fieldstring); | |
$result = curl_exec($ch); | |
curl_close($ch); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
FYI This endpoint has been changed to
https://webto.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8