Home > Backend Development > PHP Tutorial > php出现curl 35号错误怎么办

php出现curl 35号错误怎么办

PHPz
Release: 2020-09-05 10:42:17
Original
5196 people have browsed it

php出现curl 35号错误怎么办

php出现curl 35号错误怎么办?

PHP开发-用curl向https发请求时的35号错误

放了个假发现以前写的程序的模拟登陆不管用了,中间输出,发现curl向https发请求时没有返回数据,输出错误信息,得到:

curl_errno($ch) -----> 35
curl_error($ch) -----> error:14077458:SSL routines:SSL23_GET_SERVER_HELLO:reason(1112)
Copy after login

查了很多资料,终于发现要强行指定SSL的版本,即加上下面的话就可以了:

curl_setopt($ch, CURLOPT_SSLVERSION, 3);
Copy after login

整个函数也贴下来供参考:

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;
}
Copy after login

更多相关知识,请访问PHP中文网

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template