有时候我们需要请求谷歌https的数据 或者其他接口的数据 、这个时候就需要使用curl https了 echo curlhttps("https://www.google.com"); function curlhttps($url){ $user_agent = "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,$url); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); curl_setopt($ch, CURLOPT_USERAGENT, $user_agent); curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); // this line makes it work under https $result=curl_exec ($ch); curl_close ($ch); return $result; }
关键字词: