APlayer_Plugin::fetch_url PHP Method

fetch_url() private static method

url抓取,两种方式,优先用curl,当主机不支持curl时候采用file_get_contents
private static fetch_url ( unknown $url ) : boolean | mixed
$url unknown
return boolean | mixed
    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;
        }
    }