怎么用CURL向HTTPS发送请求并且获取返回值
$header = array (
'User-Agent: Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.146 Safari/537.36'
);
$ch = curl_init ();
curl_setopt ($ch, CURLOPT_TIMEOUT, 6); // 设置超时6秒
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, FALSE); // 跳过SSL
curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, FALSE); // 跳过SSL
curl_setopt ($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
// 执行
$content = curl_exec ( $ch );
if ($content == FALSE) {
curl_error ( $ch );
return true;
}
// 关闭
curl_close ( $ch );