报错:
解决方式:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
//设置为不是https也可以访问
curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST,0);
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER,0);
$result = curl_exec($ch);
curl_close($ch);
$ret = json_decode($result);
return $ret;
主要添加的代码:
//设置为不是https也可以访问
curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST,0);
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER,0);
注意:开启curl扩展和OpenSSL扩展