打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
curl 远程跨域请求
function curl_request($url,$post='',$cookie='', $returnCookie=0){        $curl = curl_init();        curl_setopt($curl, CURLOPT_URL, $url);        curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/6.0)');        curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);        curl_setopt($curl, CURLOPT_AUTOREFERER, 1);        curl_setopt($curl, CURLOPT_REFERER, "http://XXX");        if($post) {            curl_setopt($curl, CURLOPT_POST, 1);            curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($post));        }        if($cookie) {            curl_setopt($curl, CURLOPT_COOKIE, $cookie);        }        curl_setopt($curl, CURLOPT_HEADER, $returnCookie);        curl_setopt($curl, CURLOPT_TIMEOUT, 10);        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);        $data = curl_exec($curl);        if (curl_errno($curl)) {            return curl_error($curl);        }        curl_close($curl);        if($returnCookie){            list($header, $body) = explode("\r\n\r\n", $data, 2);            preg_match_all("/Set\-Cookie:([^;]*);/", $header, $matches);            $info['cookie']  = substr($matches[1][0], 1);            $info['content'] = $body;            return $info;        }else{            return $data;        }}
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
!!!!! php 使用curl模拟登录discuz以及模拟发帖 | SimonLeung's Blo...
CURL不依赖COOKIEJAR获取COOKIE喵了个咪 | PHP/PHP框架 | 喵了个咪
奇艺(奇艺果)的解析源码
PHP中cURL获取数据处理的几种方法
curl class
php curl_init函数用法
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服