php开发-用curl向https发请求时的35号错误
放了个假发现以前写的程序的模拟登陆不管用了,中间输出,发现curl向https发请求时没有返回数据,输出错误信息,得到:
curl_errno($ch) -----> 35curl_error($ch) -----> error:14077458:ssl routines:ssl23_get_server_hello:reason(1112)
查了很多资料,终于发现要强行指定ssl的版本,即加上下面的话就可以了:
curl_setopt($ch, curlopt_sslversion, 3);
整个函数也贴下来供参考:
function sendposthttps($url, $postdata, $header=0, $referer=""){ $ch = curl_init () ; curl_setopt($ch, curlopt_post, 1); curl_setopt($ch, curlopt_header, $header); curl_setopt($ch, curlopt_returntransfer, true); curl_setopt($ch, curlopt_url, $url) ; curl_setopt($ch, curlopt_postfields, $postdata); curl_setopt($ch, curlopt_referer, $referer); curl_setopt($curl, curlopt_useragent, $_server['http_user_agent']); curl_setopt($ch, curlopt_ssl_verifypeer, 0); curl_setopt($ch, curlopt_ssl_verifyhost, 1); curl_setopt($ch, curlopt_sslversion, 3); $result = curl_exec($ch); curl_close($ch); return $result;}
更多相关知识,请访问!
