远程获取数据，GET模式
注意：
1.使用curl需要修改服务器中php.ini文件的设置，找到php_curl.dll去掉前面的";"就行了
2.文件夹中cacert.pem是SSL证书请保证其路径有效，目前默认路径是：getcwd().'\\cacert.pem'

@param $url 指定URL完整路径地址
@param $cacert_url 指定当前工作目录绝对路径
@return mixed 远程输出的数据
431714
public static function curlGet($url, $cacert_url)
    {
        $curl = curl_init($url);
        curl_setopt($curl, CURLOPT_HEADER, 0 ); // 过滤HTTP头
        curl_setopt($curl,CURLOPT_RETURNTRANSFER, 1);// 显示输出结果
        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, true);//SSL证书认证
        curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 2);//严格认证
        curl_setopt($curl, CURLOPT_CAINFO,$cacert_url);//证书地址
        $responseText = curl_exec($curl);

        if ($responseText === false) {
            $responseText = curl_error($curl);
        }
        curl_close($curl);

        return $responseText;
    }
571787
public static function fetchTinyUrl($url)
    {
        $ch = curl_init();
        $timeout = 5;
        curl_setopt($ch, CURLOPT_URL, 'http://tinyurl.com/api-create.php?url=' . $url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
        $data = curl_exec($ch);
        curl_close($ch);

	    return $data;
    }
351278
private function getUrl($url)
	{
		$ch = curl_init();
		curl_setopt($ch,CURLOPT_URL,$url);
		curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
		curl_setopt($ch,CURLOPT_HEADER,0);
		// curl_setopt($ch, CURLOPT_ENCODING, "");
		$output = curl_exec($ch);
		curl_close($ch);
	    return $output;
	}
219084
public function get($url) {
        // Ensure we have the allow_url_fopen directive enabled
        if (!$this->isSupported()) {
            $this->logger->error("allow_url_fopen is disabled.");
            throw new UnsupportedException('allow_url_fopen disabled.');
        }
        $this->logger->info("allow_url_fopen is enabled.");

        $context = stream_context_create(array(
            'http' => array(
                'user_agent'          => 'xsist10-PHP-client'
            ),
            'ssl' => array(
                'method'              => 'GET',
                'verify_peer'         => true,
                'verify_depth'        => 5,
                // Manually specify CA certificate store and CN_match requirement
                'cafile'              => __DIR__ . '/../../cacert.pem',
                'CN_match'            => 'www.haveibeenpwned.com',
                // Disabled to prevent CRIME/BEAST attacks
                // https://en.wikipedia.org/wiki/BEAST_attack#CRIME_and_BREACH_attacks
                'disable_compression' => true
            )
        ));
        
        return @file_get_contents($url, false, $context);
    }
906217
static function Get($url, $data = "", $verify_cert = false, $timeout = 30)
	{
		if (function_exists("curl_init"))
		{
			return HttpRequest::CurlPost($url, $data, $verify_cert, $timeout);
		}
		else
		{
			return HttpRequest::FilePost($url, $data, $verify_cert, $timeout);
		}
	}
881303
protected function getWebPage($url)
    {
        $curl = curl_init();

        curl_setopt($curl, CURLOPT_URL,            $url);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($curl, CURLOPT_HEADER,         false);
        curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
        $output = curl_exec($curl);
        curl_close($curl);

        return (string) $output;
    }
318778
public function url_get_contents($url) {

        $content = '';

		if (\function_exists('curl_exec')){
            $conn = \curl_init($url);
            \curl_setopt($conn, CURLOPT_SSL_VERIFYPEER, true);
            \curl_setopt($conn, CURLOPT_FRESH_CONNECT,  true);
            \curl_setopt($conn, CURLOPT_RETURNTRANSFER, 1);
            \curl_setopt($conn,CURLOPT_USERAGENT,'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.52 Safari/537.17');
            \curl_setopt($conn, CURLOPT_AUTOREFERER, true);
            \curl_setopt($conn, CURLOPT_FOLLOWLOCATION, 1);
            \curl_setopt($conn, CURLOPT_VERBOSE, 0);
            $content = (\curl_exec($conn));
            \curl_close($conn);
        }
        if (!$content && \function_exists('file_get_contents')){
            $content = @\file_get_contents($url);
        }
        if (!$content && \function_exists('fopen') && function_exists('stream_get_contents')){
            $handle  = @\fopen ($url, "r");
            $content = @\stream_get_contents($handle);
        }
        return $content;
	}
820434
public static function phpGet($url, $timeout = 5, $header = "")
    {
        $header = empty($header) ? self::defaultHeader() : $header;
        $opts = [
            'http' => [
                'protocol_version' => '1.0', //http协议版本(若不指定php5.2系默认为http1.0)
                'method' => "GET", //获取方式
                'timeout' => $timeout, //超时时间
                'header' => $header
            ]
        ];
        $context = stream_context_create($opts);
        return @file_get_contents($url, false, $context);
    }
646081
public static function verify($url, $caDir)
    {
        static $hostsByDir = [];
        
        if (!isset($hostsByDir[$caDir])) {
            $hostsByDir[$caDir] = [];
        }
        
        $extensions = ['crt', 'pem', 'cer', 'der'];
        
        // Must be https
        if (substr($url, 0, 5) != 'https') {
            return false;
        }
        
        // Default
        $defaultCA = $caDir . 'curl-ca-bundle.crt';
        
        // Look for a host specific CA file
        $host = strtolower(parse_url($url, PHP_URL_HOST));
        if (!$host) {
            return $defaultCA;
        }
        
        if (array_key_exists($host, $hostsByDir[$caDir])) {
            return $hostsByDir[$caDir][$host];
        }
        
        $filename = $host;
        do {
            // Look for the possible extensions
            foreach ($extensions as $ext) {
                if (file_exists($verify = $caDir . $filename . '.' . $ext)) {
                    $hostsByDir[$caDir][$host] = $verify;
                    return $verify;
                }
            }
            
            // Remove a subdomain each time
            $filename = substr($filename, strpos($filename, '.') + 1);
        } while (substr_count($filename, '.') > 0);
        
        // No specific match
        $hostsByDir[$caDir][$host] = $defaultCA;
        return $defaultCA;
    }
260675
public function curl($url)
    {
        $ip = '127.0.0.1';
        $port = '9051';
        $auth = 'PASSWORD';
        $command = 'signal NEWNYM';

        $fp = fsockopen($ip, $port, $error_number, $err_string, 2);
        if (!$fp) {
            echo "ERROR: $error_number : $err_string";

            return false;
        } else {
            fwrite($fp, "AUTHENTICATE \"".$auth."\"\n");
            fread($fp, 512);
            fwrite($fp, $command."\n");
            fread($fp, 512);
        }

        fclose($fp);

        $ch = curl_init();

        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_PROXY, '127.0.0.1:9050');
        curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_VERBOSE, 0);
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
        curl_setopt($ch, CURLOPT_USERAGENT, $this->getUserAgent());  // $this->getUserAgent(true) for random);
        curl_setopt($ch, CURLOPT_ENCODING , 'gzip');
        $response = curl_exec($ch);

        return [$response, $ch];
    }
304256
public function getJsApiPackage($url = null)
    {
        $jsapiTicket = $this->getJsApiTicket();

        if (is_null($url)) {
            $protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) ? 'https://' : 'http://';
            $url = $protocol.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
        }

        $timestamp = time();
        $nonceStr = base64_encode(openssl_random_pseudo_bytes(24));

        // 这里参数的顺序要按照 key 值 ASCII 码升序排序
        $string = "jsapi_ticket={$jsapiTicket}&noncestr={$nonceStr}&timestamp={$timestamp}&url={$url}";

        $signature = sha1($string);

        $signPackage = [
          'appid' => $this->getConfig('appid'),
          'nonceStr' => $nonceStr,
          'timestamp' => $timestamp,
          'url' => $url,
          'signature' => $signature,
          'rawString' => $string,
        ];

        return $signPackage;
    }
750536
function loadCRL($crl)
    {
        $asn1 = new File_ASN1();

        $temp = preg_replace('#^(?:[^-].+[\r\n]+)+|-.+-|[\r\n]| #', '', $csr);
        $temp = preg_match('#^[a-zA-Z\d/+]*={0,2}$#', $temp) ? base64_decode($temp) : false;
        if ($temp != false) {
            $crl = $temp;
        }
        $orig = $crl;

        if ($crl === false) {
            $this->currentCert = false;
            return false;
        }

        $asn1->loadOIDs($this->oids);
        $decoded = $asn1->decodeBER($crl);

        if (empty($decoded)) {
            $this->currentCert = false;
            return false;
        }

        $crl = $asn1->asn1map($decoded[0], $this->CertificateList);
        if (!isset($crl) || $crl === false) {
            $this->currentCert = false;
            return false;
        }

        $this->signatureSubject = substr($orig, $decoded[0]['content'][0]['start'], $decoded[0]['content'][0]['length']);

        $this->_mapInExtensions($crl, 'tbsCertList/crlExtensions', $asn1);
        $rclist = &$this->_subArray($crl,'tbsCertList/revokedCertificates');
        if (is_array($rclist)) {
            foreach ($rclist as $i => $extension) {
                $this->_mapInExtensions($rclist, "$i/crlEntryExtensions", $asn1);
            }
        }

        $this->currentKeyIdentifier = NULL;
        $this->currentCert = $crl;

        return $crl;
    }
201048
private static function GetTokenFromUrl($url) {
    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
    $response = curl_exec($ch);
    $headers = curl_getinfo($ch);
    curl_close($ch);

    if ($headers['http_code'] != 200) {
      throw new OAuthException($response);
    }

    return self::GetTokenFromQueryString($response);
  }
297449
public static function curlGet($url)
    {   
        $defaults = array(
            CURLOPT_URL => $url,
            //CURLOPT_HEADER => 0,
            CURLOPT_RETURNTRANSFER => TRUE,
            //CURLOPT_TIMEOUT => 4
        );
       
        $ch = curl_init();
        curl_setopt_array($ch, $defaults);
        if( ! $result = curl_exec($ch))
        {
            trigger_error(curl_error($ch));
        }
        curl_close($ch);
        return $result;
    }
952830
protected static function fetchUrl($url) {
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_HTTPHEADER, ['User-Agent: Mozilla/5.0 (OSX) Gecko/20030208 Netscape/7.02']);
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_HEADER, 1);
        
        $response = curl_exec($ch);
        
        $httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
        $header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
        $headers = substr($response, 0, $header_size);
        $body = substr($response, $header_size);
        
        // XXX check HTTP code
        // 404 -> not found
        // 200 -> ok
        // other -> fail
        
        return [
            'code' => $httpcode,
            'headers' => $headers,
            'body' => $body
        ];
    }
105533
function fetchURL ($url, $param) {
        $return = array();
        
        $ch = curl_init();
        
        curl_setopt($ch,CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch,CURLOPT_TIMEOUT, 0);
        curl_setopt($ch,CURLOPT_FORBID_REUSE, 1);
        curl_setopt($ch,CURLOPT_FRESH_CONNECT, 1);
        curl_setopt($ch,CURLOPT_HEADER, 1);
        curl_setopt($ch,CURLOPT_URL,$url);
        if ($this->disableSslVerify) {
            $this->log('Caution: Request being sent without SSL verification.', 'Warning');
            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
            curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
        }
        if (!empty($param)){
            if (!empty($param['Header'])){
                curl_setopt($ch,CURLOPT_HTTPHEADER, $param['Header']);
            }
            if (!empty($param['Post'])){
                curl_setopt($ch,CURLOPT_POSTFIELDS, $param['Post']);
            }
        }
        
        $data = curl_exec($ch);
        if ( curl_errno($ch) ) {
                $return['ok'] = -1;
                $return['error'] = curl_error($ch);
                return $return;
        }
        
        if (is_numeric(strpos($data, 'HTTP/1.1 100 Continue'))) {
            $data=str_replace('HTTP/1.1 100 Continue', '', $data);
        }
        $data = preg_split("/\r\n\r\n/",$data, 2, PREG_SPLIT_NO_EMPTY);
        if (!empty($data)) {
                $return['head'] = ( isset($data[0]) ? $data[0] : null );
                $return['body'] = ( isset($data[1]) ? $data[1] : null );
        } else {
                $return['head'] = null;
                $return['body'] = null;
        }
        
        $matches = array();
        $data = preg_match("/HTTP\/[0-9.]+ ([0-9]+) (.+)\r\n/",$return['head'], $matches);
        if (!empty($matches)) {
                $return['code'] = $matches[1];
                $return['answer'] = $matches[2];
        }
        
        $data = preg_match("/meta http-equiv=.refresh. +content=.[0-9]*;url=([^'\"]*)/i",$return['body'], $matches);
        if (!empty($matches)) {
                $return['location'] = $matches[1];
                $return['code'] = '301';
        }
        
        if ( $return['code'] == '200' || $return['code'] == '302' ) {
                $return['ok'] = 1;
        } else {
                $return['error'] = (($return['answer'] and $return['answer'] != 'OK') ? $return['answer'] : 'Something wrong!');
                $return['ok'] = 0;
        }
        
        foreach (preg_split('/\n/', $return['head'], -1, PREG_SPLIT_NO_EMPTY) as $value) {
                $data = preg_split('/:/', $value, 2, PREG_SPLIT_NO_EMPTY);
                if (is_array($data) and isset($data['1'])) {
                        $return['headarray'][$data['0']] = trim($data['1']);
                }
        }
        
        curl_close($ch);
        
        return $return;
       }
640243
protected function _downloadCurl($url)
    {
        $curl = curl_init();
        curl_setopt($curl, CURLOPT_URL, $url);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
        if ($this->sslVerifyHost) {
            curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 2);
        } else {
            curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
        }
        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, $this->sslVerifyHost);
        $update = curl_exec($curl);

        $error = false;
        if (curl_error($curl)) {
            $error = true;
            $this->log->addError(sprintf(
                'Could not download update "%s" via curl: %s!',
                $url,
                curl_error($curl)
            ));
        }
        curl_close($curl);

        if ($error === true) {
            return false;
        }

        return $update;
    }