drb56625 2013-02-14 11:35
浏览 58
已采纳

PHP Curl登录Tesco Mobile

I am trying to login into Tesco Mobile, using PHP curl, I have the following code:

$postData='user=XXX&password=XXXXX';

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://paymonthly.tescomobile.com/orderentry/LoginSubmit.do');
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, TRUE); 
curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6"); 
curl_setopt ($ch, CURLOPT_TIMEOUT, 60); 
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1); 
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); 
curl_setopt($ch, CURLOPT_COOKIEJAR, "cookies.txt");
curl_setopt($ch, CURLOPT_COOKIEFILE, "cookies.txt");
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_REFERER, 'https://paymonthly.tescomobile.com/orderentry/LoginSubmit.do');
curl_setopt ($ch, CURLOPT_POSTFIELDS, $postdata); 
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);     
$result = curl_exec ($ch); 
curl_close($ch);

But have been unsuccessful, please can anyone help how I can achieve this. Please find the output from Live HTTP below:

Thanks in advance.

https://paymonthly.tescomobile.com/orderentry/LoginSubmit.do

POST /orderentry/LoginSubmit.do HTTP/1.1 Host: paymonthly.tescomobile.com User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:18.0) Gecko/20100101 Firefox/18.0 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8 Accept-Language: en-US,en;q=0.5 Accept-Encoding: gzip, deflate Referer: https://paymonthly.tescomobile.com/orderentry/LoginSubmit.do;jsessionid=60af415cd448d5728a9fa98cdf99 Cookie: JSESSIONID=60af415cd448d5728a9fa98cdf99; reevoomark_marker=349049566; reevoo_utma=1.324660794.1360800582.1360800582.1360800582.1; reevoo_utmb=1.5.6.1360800582; reevoo_utmc=1; reevoo_utmz=1.1360800582.1.1.utmgclid=CK6Vp5nBtLUCFeXKtAodVGIAVA|utmccn=(not%20set)|utmcmd=(not%20set)|utmctr=tescomobile; reevoomark_bh_session=0af0a16fc00f5fbc8b0d28c571721a72; CUSTOMER_UUID=04fdc3e6-59e1-4038-81b7-ec7c5d63c9d4; __utma=152930744.490151867.1360800710.1360800710.1360800710.1; __utmb=152930744; __utmc=152930744; __utmz=152930744.1360800710.1.1.utmccn=(referral)|utmcsr=phone-shop.tesco.com|utmcct=/tesco-mobile/my-tesco-mobile/|utmcmd=referral Connection: keep-alive Content-Type: application/x-www-form-urlencoded Content-Length: 32 user=dinoc83&password=c079378643 HTTP/1.1 200 OK X-Powered-By: JSP/2.1 Server: Sun GlassFish Enterprise Server v2.1.1 Content-Type: text/html;charset=UTF-8 Transfer-Encoding: chunked Date:

Thu, 14 Feb 2013 00:15:27 GMT

  • 写回答

4条回答 默认 最新

  • dongrou5254 2013-02-14 11:51
    关注

    Just checked form

    Form attribute action have parameter jsessionid In your code you don't use it. I think you should in first load page with form, then parse response code and get correct URL for post. And this need for initialize cookies.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题