php用curl的post

备份一下curl的post用法,因为很多时候都会出错,所以备份一下,$data是字符串例如:id=1&type=2之类的

function curl_post($url,$referer,$data){
        $ch=curl_init();
        curl_setopt($ch, CURLOPT_REFERER,$referer);//referer地址
        curl_setopt($ch, CURLOPT_DNS_USE_GLOBAL_CACHE, false);    
        curl_setopt($ch, CURLOPT_URL, $url);   
        curl_setopt($ch, CURLOPT_POST, 1);   
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $data); 
        $contents=curl_exec($ch);
        return $contents;
}

php用curl的post:等您坐沙发呢!

发表评论

表情
还能输入210个字