Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/269.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 无法通过curl执行url_Php_Curl - Fatal编程技术网

Php 无法通过curl执行url

Php 无法通过curl执行url,php,curl,Php,Curl,我无法通过curl执行URL。但是,如果只是通过浏览器运行查询,它就可以正常工作。我的代码如下: $xmlData = "<Leads><row no='1'><FL val='First Name'>".$new_fname."</FL><FL val='Last Name'>".$new_lname."</FL><FL val='Email'>".$new_email."</FL><FL v

我无法通过curl执行URL。但是,如果只是通过浏览器运行查询,它就可以正常工作。我的代码如下:

$xmlData = "<Leads><row no='1'><FL val='First Name'>".$new_fname."</FL><FL val='Last Name'>".$new_lname."</FL><FL val='Email'>".$new_email."</FL><FL val='Phone'>".$new_ph_no."</FL></row></Leads>";
$xmlData = htmlentities($xmlData);
$ch = curl_init("https://crm.zoho.com/crm/private/xml/Leads/insertRecords?newFormat=1&authtoken=XXX&scope=crmapi&xmlData=".$xmlData);
curl_setopt($ch, CURLOPT_VERBOSE, 1);//standard i/o streams 
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, TRUE);// Turn off the server and peer verification 
curl_setopt($ch, CURLOPT_SSL_CIPHER_LIST, 'rsa_rc4_128_sha'); //for godaddy server patch
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);//Set to return data to string ($response) 
curl_setopt($ch, CURLOPT_POST, 1);//Regular post 
$response = curl_exec($ch); 
curl_close($ch);
$xmlData=”“.$new\u fname.“$new\u lname.”“$new\u email.“$new\u ph\u no.”;
$xmlData=htmlentities($xmlData);
$ch=curl_init(“https://crm.zoho.com/crm/private/xml/Leads/insertRecords?newFormat=1&authtoken=XXX&scope=crmapi&xmlData=“$xmlData);
curl_setopt($ch,CURLOPT_VERBOSE,1)//标准i/o流
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,TRUE);//关闭服务器和对等验证
curl_setopt($ch,CURLOPT_SSL_CIPHER_LIST,'rsa_rc4_128_sha')//用于godaddy服务器修补程序
curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,FALSE);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1)//设置为将数据返回到字符串($response)
卷曲设置($ch,卷曲设置桩,1)//正规职务
$response=curl\u exec($ch);
卷曲关闭($ch);
你能告诉我问题出在哪里吗?
提前感谢。

以下代码应该可以工作:

$ch = curl_init("https://crm.zoho.com/crm/private/xml/Leads/insertRecords?newFormat=1&authtoken=XXX&scope=crmapi&xmlData=".$xmlData);

curl_setopt($ch, CURLOPT_VERBOSE, 1); 
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
// deactivate certificate checking 
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);//Set to return data to string ($response) 
curl_setopt($ch, CURLOPT_POST, 1);//Regular post 
$response = curl_exec($ch); 

if(!$response) {
    echo curl_error($ch), PHP_EOL;
}
curl_close($ch);
经过讨论,我意识到问题在于,您尚未在系统上安装Thawte ssl证书。您有两个选择:

  • 安装
  • 使用
    CURLOPT\u VERIFYPEER=FALSE禁用证书检查

在我的示例中,我使用了第二种方法来演示如何使代码正常工作。对于生产系统,我建议您安装证书。

您能描述一下您遇到的实际问题/错误吗?使用
curl\u error()
查看问题是什么您通过浏览器发出post请求?请在此处发布错误。。我得到了“设置密码列表失败”。我得到了以下错误:SSL证书问题,验证CA证书是否正常。详细信息:错误:14090086:SSL例程:SSL3_获取_服务器_证书:证书验证失败但在您的场景中,它显示“SSL证书验证正常”,但为什么现在为我显示“我得到错误”。您使用的是什么操作系统?Linux?您得到的错误意味着您尚未导入Thawte证书。您有两种选择:跳过验证或导入证书我认为在您的情况下最好的方法是禁用证书检查。检查我的更新