How to move from ...
file_get_contents ()
for CURL or Guzzle
$content = http_build_query(array(
'oid' => '00SH1000000ASZF',
'retURL' => 'https://www.site.com.br/',
'first_name' => $nome,
'last_name' => $sobrenome,
'cpf__c' => rmCaracter($f['cpf']),
'mobile' => rmCaracter($f['phone']),
'email' => $f['email'],
'type__c' => 'HAB',
'Lead_Source' => 'Website Concessionaria',
'sub_source_media__c' => 'Site',
'dealer_code_interest__c' => '137492',
'opt_in_email__c' => '1',
'opt_in_phone__c' => '1',
'model_interest__c' => $f['model'],
));
$context = stream_context_create(array(
'http' => array(
'method' => 'POST',
'content' => $content,
)
));
$result = file_get_contents('https://webto.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8', null, $context);
I'm getting an error in $ result . ::
Warning: file_get_contents ( link ...): failed to open stream: HTTP request failed! HTTP / 1.1 400 TLS 1.1 or higher required in /home/storage/9/8e/3d/teste1124/public_html/tpl/site.php on line 124
I think it's the Solution because, if I put the url of this webservice in the action of a form and send the same data, I do not have the error, but the way I mounted my json, ai.
My Form + Json = link
Most hosts now block the furl_open parameter that allows you to use file_get_contents () to load data from a URL external. I think I can use CURL or a PHP client library like Guzzle, as a solution.