private static function fetch_url($url)
{
if (function_exists('curl_init')) {
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 15);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$output = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($httpCode != 200) {
return false;
}
return $output;
} else {
//若主机不支持openssl则file_get_contents不能打开https的url
if ($result = @file_get_contents($url)) {
if (strpos($http_response_header[0], '200')) {
return $result;
}
}
return false;
}
}