-
-
Save mahfuzul/5a8da362e03c5a82634b7fd9af753fa8 to your computer and use it in GitHub Desktop.
Salesforce web to lead via php-curl.
This file contains hidden or 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://www.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