CURL如何获取HTTPS协议的状态码
程序员文章站
2024-01-21 16:28:46
...
$curl = curl_init();$url='https://';curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_HEADER, 1); curl_setopt($curl,CURLOPT_NOBODY,true); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); $data = curl_exec($curl); echo curl_getinfo($curl,CURLINFO_HTTP_CODE); curl_close($curl);
我用这种方法打印出http的状态码没问题,但是换成https协议一直输出0. 请问https应该怎么获取
回复讨论(解决方案)
https ?求?要加上
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // 跳过证书检查
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); // 从证书中检查SSL加密算法是否存在
'fdipzone');$header = array();list($code, $response) = curl_https($url, $data, $header, 5);echo $code;echo $response;?>