PHP CURL 无法下载的原因,https站点

现象

使用php curl下载,http站点可以,https站点抓取不到内容。

解决办法

增加3行

 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
 curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
 curl_setopt($ch, CURLOPT_CAINFO, \Yii::getAlias('@app/config/cacert.pem'));

下载 cacert.pem

下载地址:https://curl.haxx.se/docs/caextract.html

猜你喜欢

转载自blog.csdn.net/default7/article/details/80912415
今日推荐