CURL ERROR: Recv failure: Connection reset by peer
2020-12-18 08:58:28 阅读:1884
绕过ssl验证就可以:curl_setopt($c,CURLOPT_SSL_VERIFYPEER,false);curl_setopt($c,CURLOPT_SSL_VERIFYHOST,false);下面是我的完整代码:functiongit_curl_data($url,$params=false,$ispost=0)
{
$httpInfo=array();
$ch=curl_init();
curl_setopt($ch,CURLOPT_HTTP_VERSION,CURL_HTTP_VERSION_1_1);
curl_setopt($ch,CURLOPT_USERAGENT,'Mozilla/5.0(WindowsNT5.1)AppleWebKit/537.22(KHTML,likeGecko)Chrome/25.0.1364.172Safari/537.22');
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,30);
curl_setopt($ch,CURLOPT_TIMEOUT,30);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
if($ispost){
curl_setopt($ch,CURLOPT_POST,true);
curl_setopt($ch,CURLOPT_POSTFIELDS,$params);
curl_setopt($ch,CURLOPT_URL,$url);
}else{
if($params){
curl_setopt($ch,CURLOPT_URL,$url.'?'.$params);
}else{
curl_setopt($ch,CURLOPT_URL,$url);
}
}curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,false);curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,false);$response=curl_exec($ch);if($response===FALSE){returnfalse;}$httpCode=curl_getinfo($ch,CURLINFO_HTTP_CODE);$httpInfo=array_merge($httpInfo,curl_getinfo($ch));curl_close($ch);return$response;}