微学网

热门关键词:   as  thinkphp  ecshop  xxx  商务通  www.ymwears.cn
热门: ASP.NET PHP编程 ASP编程 JSP编程 Python

PHP post数据并携带cookie发送请求【实例tx课堂post数据】

发布时间:2021-04-01 来源:未知 点击:

站长亲测,直接发代码吧,有兴趣的朋友研究一下.

<?php

//配置登陆信息
$header = array(
        "Host:ke.qq.com",
        //'Content-Type:application/x-www-form-urlencoded',
        'Cookie:pgv_pvid=2312921424; pgv_pvi=4247474176; RK=MK7cDgdDfG; ptcz=8cdc9971d897e7c038f7921f8d3562987abd82f4080bddf4b66a99c25c3cecd2; tvfe_boss_uuid=386fb7ff01872b6e; o_cookie=434818735; eas_sid=A105k8E9L7p6D0T0n9R6D506D6; pac_uid=1_2389848282; psrf_qqopenid=C711D6E7491AB5D3FD4D6E8ACDEBA567; euin=7eoPNe6F7iok; psrf_access_token_expiresAt=1624189026; tmeLoginType=2; psrf_qqrefresh_token=2BF30500F5F66255EB71732247735007; psrf_qqunionid=; psrf_qqaccess_token=19872125B63647A18E7A450CEC9088D7; iip=0; sd_userid=60111616770598796; sd_cookie_crttime=1616770598796; pgv_info=ssid=s2648184980; _qpsvr_localtk=0.14215208907997134; tdw_data_new_2={\"auin\":\"-\",\"sourcetype\":\"\",\"sourcefrom\":\"\",\"ver9\":2389848282,\"uin\":2389848282,\"visitor_id\":\"38907612140329906\"}; _pathcode=0.6856610028244499; tdw_auin_data=-; tdw_data={\"ver4\":\"www.baidu.com\",\"ver5\":\"\",\"ver6\":\"\",\"refer\":\"www.baidu.com\",\"from_channel\":\"\",\"path\":\"reBhbBarh-0.6856610028244499\",\"auin\":\"-\",\"uin\":2389848282,\"real_uin\":\"2389848282\"}; tdw_data_testid=; tdw_data_flowid=; tdw_first_visited=1; stop_remind_zoom=stop_remind_zoom; ke_login_type=1; miniapp_qrcode_id=d83fe9d92bba446da5d6b690a1abae42; uin=o2389848282; [email protected]; luin=o2389848282; lskey=00010000823b1e0099c43a840587e5e5b873f6dd27fd0acc6f2132f26f3bf707973481785fdbc73ad9181a97; p_uin=o2389848282; pt4_token=PWMl5cLW9iRueEAJ7sGpmlFuAqAtEcVChZgXuSqOyMU_; p_skey=9DphHSR6gom2GbbODX9SrQ6UTbmtwSLwvK-nO*0NP0w_; p_luin=o2389848282; p_lskey=000400007d427c1283dc8ddee4945170496ff85e5a38928471b83c19e20672edd3a992b27b270ca70e041108; tdw_data_sessionid=1617245210905387985268; ts_last=ke.qq.com/course/2587232; ts_uid=1292443600; Hm_lvt_0c196c536f609d373a16d246a117fd44=1615206772,1617245211; Hm_lpvt_0c196c536f609d373a16d246a117fd44=1617245342; iswebp=1; report_position_key={\"url_position\":\"\",\"url_module\":\"\",\"url_page\":\"distributionmall\"}',
        'Origin: https://ke.qq.com',
        'X-Requested-With: XMLHttpRequest',
        'Referer:https://ke.qq.com/sale.html',
        );
      
      
      
      
//优先评论操作
$url_pl="https://ke.qq.com/cgi-bin/ke_distribution/courseList?page=1&count=10&type=1&bkn=642218075&r=0.15042221471894546";
$post_data = array(
);
$ret = curl_post($header,$post_data,$url_pl);
$ret2 = json_decode($ret,true);

/**
 * 发送post请求
 * @param string $url 请求地址
 * @param array $post_data post键值对数据
 * @return string
 */
function curl_post($header,$data,$url)
    {
     $ch = curl_init();
     $res= curl_setopt ($ch, CURLOPT_URL,$url);
     curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
     curl_setopt ($ch, CURLOPT_HEADER, 0);
     curl_setopt($ch, CURLOPT_POST, 1);
     curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
     curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($ch,CURLOPT_HTTPHEADER,$header);
     curl_setopt ($ch, CURLOPT_REFERER, "https://ke.qq.com/sale.html");
     $result = curl_exec ($ch);
     //var_dump($result);
     curl_close($ch);
     if ($result == NULL) {
      return 0;
     }
     return $result;
    }
?>

这就是微学网-程序员之家为你提供的"PHP post数据并携带cookie发送请求【实例tx课堂post数据】"希望对你有所帮助.本文来自网络,转载请注明出处:http://www.weixuecn.cn/article/14093.html
网络编程 | 前端制作 | 数据库 | CMS教程 | 脚本编程 | 框架 | 服务器 | 微信开发 | APP开发 |

凡本网站转载的文章、图片等资料的版权归版权所有人所有,因无法和版权所有者一一联系,如果本网站选取的文/图威胁到您的权益,请您及时和本网站联系。 我们会在第一时间内采取措施,避免给双方造 成不必要的损失。
© 2015-2021 微学网 版权所有,并保留所有权利。 备案号:粤ICP备09051474号-1

菜鸟教程,提供各类程序编程入门,技巧