tianqixin

PHP CURL 访问的如果是 https 协议,需要添加以下语句:

curl_setopt($ch,CURLOPT_SSL_VERIFYPEER, false)

实例:

$url = 'https://www.runoob.com'; 
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_HEADER, 1);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);// 这个是主要参数
$data = curl_exec($curl); 
curl_close($curl);
var_dump($data);