Home > php教程 > php手册 > body text

php curl常见错误:SSL错误、bool(false)

WBOY
Release: 2016-05-25 16:52:59
Original
1450 people have browsed it

症状:php curl调用https出错

排查方法:在命令行中使用curl调用试试。

原因:服务器所在机房无法验证SSL证书。

解决办法:跳过SSL证书检查,代码如下:

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); 

症状:php curl调用curl_exec返回bool(false),命令行curl调用正常。

排查方法:var_dump(curl_error($ch));

返回:string(23) "Empty reply from server"

再排查,代码如下:

curl_setopt($ch, CURLOPT_HEADER, true);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, false);

返回:HTTP/1.1 100 Continue Connection: close

原因:php curl接收到HTTP 100就结束了,应该继续接收HTTP 200

解决方案,代码如下: curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:'));

Related labels:
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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template