普通的curl访问并获取输出内容

<?php

function login_post($url, $encoding = null, $timeout = 10000, $httpActionType = ‘Get‘, $postParameter = "") {
  $encoding == null ? ‘gb2312‘ : $encoding;

        if ($httpActionType == ‘Get‘) {
            $curl = curl_init($url);
            curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
            curl_setopt($curl, CURLOPT_HTTPHEADER, array(‘Accept-Encoding: gzip, deflate‘));
            curl_setopt($curl, CURLOPT_ENCODING, ‘gzip,deflate‘);
            curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, $timeout / 1000);
            $html = curl_exec($curl);
            curl_close($curl);
//            return iconv($encoding, ‘utf-8‘, $html);
            return $html;
        } else {
            $curl = curl_init($url);
            curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
            curl_setopt($curl, CURLOPT_POST, 1);
            curl_setopt($curl, CURLOPT_POSTFIELDS, $postParameter);
            curl_setopt($curl, CURLOPT_HTTPHEADER, array(‘Accept-Encoding: gzip, deflate‘));
            curl_setopt($curl, CURLOPT_ENCODING, ‘gzip,deflate‘);
            curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, $timeout / 1000);
            $html = curl_exec($curl);
            curl_close($curl);
            return $html;
//            return iconv($encoding, ‘utf-8‘, $html);
        }

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。