file_get_contents 得到https类型url失败的方法

file_get_contents 得到https类型url失败的方法

把file_get_contents改成下面的方法即可:

 

function getSSLPage($url) {
  $ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_HEADER, false);
  curl_setopt($ch, CURLOPT_URL, $url);
  curl_setopt($ch, CURLOPT_SSLVERSION,30); 
  $result = curl_exec($ch);
  curl_close($ch);
  return $result;
}