缘故原由:做事器所在机房无法验证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:'));
http://the-stickman.com/web-development/php-and-curl-disabling-100-continue-header/