CURL-post请求

来源:互联网 发布:wiffi转网络接口 编辑:程序博客网 时间:2024/05/17 05:05

CURL-post请求

    function postCurl($url,$data){        $ch = curl_init();        curl_setopt($ch, CURLOPT_URL, $url);        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);        curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (compatible; MSIE 5.01; Windows NT 5.0)');        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);        curl_setopt($ch, CURLOPT_AUTOREFERER, 1);        curl_setopt($ch, CURLOPT_POSTFIELDS, $data);        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);        $tmpInfo = curl_exec($ch);        if (curl_errno($ch)) {            return curl_error($ch);        }        curl_close($ch);        return $tmpInfo;    }
原创粉丝点击