You need to sign in to do that
Don't have an account?
Chris McKenzie
Web To Lead via CURL is not working anymore
Recently I got stuck with storing leads to SF via CURL calls, it was working perfectly before and somehow it stopped a few weeks ago.
I must emphasize that I didn't do any code changes which could possibly cause this function to fail.
Here is a part of my code:
//Initialize the $kv array for later use $kv = array(); foreach ($prepare_data as $key => $value) { $kv[] = stripslashes($key)."=".stripslashes($value); } //Create a query string with join function separted by & $query_string = join("&", $kv); //Check to see if cURL is installed ... if (function_exists('curl_init')) { $url = 'https://www.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8'; //Open cURL connection $ch = curl_init(); //Set the url, number of POST vars, POST data curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, count($kv)); curl_setopt($ch, CURLOPT_POSTFIELDS, $query_string); //Set some settings that make it all work :) curl_setopt($ch, CURLOPT_HEADER, FALSE); curl_setopt($ch, CURLOPT_RETURNTRANSFER, FALSE); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE); //Execute SalesForce web to lead PHP cURL $result = curl_exec($ch); //close cURL connection curl_close($ch); }
$prepare_data variable has key/value pairing of SF fields. Keys are set from the HTML generated form.
I would appreciate help from someone who else have/had similar issues to try to solve this.
Thanks in advance
Can you say more about exactly how it's "not working"? Maybe try printing the details of the transfer and pasting results back here.
Hi,
This is something I can't really explain why occurred. Everything was working and suddenly the leads stopped being saved to SF.
Here is the curl request info you asked for
That's all, there is no "redirect_url".
Do you maybe have an idea why it's stopped working suddenly without code changes?
Hi,
No problem at all, I'm glad that you're trying to help me anyway.
Hm... I don't think that TLS update is done, I think TLS 1.0 is still active.
But shouldn't I receive any error message about that?
I think I found it and it seems that you're right. I've turned on CURLOPT_HEADER and this is how response header looks like
I had the same issue.
First, I use the following to debug. I received this error: SSL certificate problem: unable to get local issuer certificate
I found this solution:
https://developer.salesforce.com/forums/?id=906F0000000BBHQIA4
Which advises to add the following: It worked, however, I didn't think that it was wise to disable host name verification.
Then I found the following solution:
http://stackoverflow.com/questions/14951802/paypal-ipn-unable-to-get-local-issuer-certificate Where 'cacert.pem' was downloaded at the following location:
https://curl.haxx.se/ca/cacert.pem
And then save at the same level than my PHP.
Now it works all fine.
Retrospectively, I believed that the issue appeared when I move my website on Azure which may have different default parameters for curl.
Hope it helps.