function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Arthur PembertonArthur Pemberton 

Web to Lead not longer working with PHP

I'm getting symptoms similiar to https://developer.salesforce.com/forums/?id=906F0000000D9pIIAS exception I'm using cURL with PHP, and I have explicitly set TLSv1.2.

I keep getting "ignore-captcha: Ignoring captcha since redirect timed out." and no leads posting. 
Bruno Bonfim AffonsoBruno Bonfim Affonso

Use cURL,it's simple. Pay attention to the URL and OID.

//url - test
$url = 'https://test.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8';

//your POST data
$fields = array('first_name'=>urlencode('Test'),
    'last_name'=>urlencode('Test'),
    'company'=>urlencode('Test Inc.'),
    'description'=>urlencode('Test'),
    'phone'=>urlencode('+55 41 0000-0000'),
    'recordType' =>urlencode(''),
    'oid' => '',
    'retURL' => urlencode('/'));

$fields_string = '';

//url-ify the data for the POST
foreach($fields as $key => $value) {
    $fields_string .= $key.'='.$value.'&';
}

$fields_string = rtrim($fields_string,'&');

//open 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($fields));
curl_setopt($ch,CURLOPT_POSTFIELDS,$fields_string);

curl_setopt($ch,CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch,CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch,CURLOPT_FOLLOWLOCATION, TRUE);

//execute post
$result = curl_exec($ch);

//close connection
curl_close($ch);