cURL不会处理登录?

时间:2016-02-26 13:50:29

标签: php curl

所以我尝试使用以下脚本从我的网站登录ROBLOX

function login($url,$username,$password){
    $fp = fopen("cookie.txt", "w");
    $data = array(
            'userName'        => $username,
            'password'        => $password,
            'isCaptchaOn'     => false,
            'challenge'       => '',
            'captchaResponse' => ''
        );
    fclose($fp);
    $login = curl_init();
    curl_setopt($login, CURLOPT_COOKIEJAR, "cookie.txt");
    curl_setopt($login, CURLOPT_COOKIEFILE, "cookie.txt");
    curl_setopt($login, CURLOPT_TIMEOUT, 40000);
    curl_setopt($login, CURLOPT_RETURNTRANSFER, TRUE);
    curl_setopt($login, CURLOPT_URL, $url);
    curl_setopt($login, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
    curl_setopt($login, CURLOPT_FOLLOWLOCATION, TRUE);
    curl_setopt($login, CURLOPT_POST, TRUE);
    curl_setopt($login, CURLOPT_POSTFIELDS, $data);
    ob_start();
    return curl_exec ($login);
    ob_end_clean();
    curl_close ($login);
    unset($login);    
}  

然而,当我尝试登录功能时,它不起作用

echo(login("https://www.roblox.com/newlogin","Username=teachinglover&Password=ya"));

它只是回声,而且功能还没有完成

知道它为什么不做任何事情?为什么它没有完成登录?!

编辑:我不确定但是我可能需要添加一些标题吗?

如果您想查看必要的POST对象

Request URL:https://www.roblox.com/newlogin
Request Method:POST
Status Code:200 OK
Remote Address:8.42.96.25:443
Response Headers
view source
Access-Control-Allow-Credentials:true
Access-Control-Allow-Origin:https://www.roblox.com
Access-Control-Expose-Headers:X-CSRF-TOKEN
Cache-Control:private
Content-Encoding:gzip
Content-Length:11961
Content-Type:text/html; charset=utf-8
Date:Fri, 26 Feb 2016 13:48:06 GMT
P3P:CP="CAO DSP COR CURa ADMa DEVa OUR IND PHY ONL UNI COM NAV INT DEM PRE"
Vary:Accept-Encoding
Request Headers
view source
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Accept-Encoding:gzip, deflate
Accept-Language:en-US,en;q=0.8
Cache-Control:max-age=0
Connection:keep-alive
Content-Length:38
Content-Type:application/x-www-form-urlencoded
Cookie:RBXSource=rbx_acquisition_time=2/17/2016 11:34:48 AM&rbx_acquisition_referrer=&rbx_medium=Direct&rbx_source=&rbx_campaign=&rbx_adgroup=&rbx_keyword=&rbx_matchtype=&rbx_send_info=1; RBXViralAcquisition=time=2/17/2016 11:34:48 AM&referrer=&originatingsite=; GuestData=UserID=-1661021767; RBXMarketing=FirstHomePageVisit=1; __gads=ID=85bb563f4079b12f:T=1455730802:S=ALNI_MbDjPeXjVm69YJMcFdVnOyw2XxWvQ; __ssid=aaf89930-bda3-4057-9fed-d5324ec16615; __RequestVerificationToken=NnycdFxv3QtmdyJPW9irh64pVurQGL4BHEjZI9kq3uET0G_NT_f0JUQlIhVsE6gUC5clWd4QoPQ3gwwDo45kif1JQHw1; glt_3_OsvmtBbTg6S_EUbwTPtbbmoihFY5ON6v6hbVrTbuqpBs7SyF_LQaJwtwKJ60sY1p=LT3_p97tsEiCJbASoKTsdz1ye4a8igDizZThXseKb-HwEYg%7CUUID%3D4169b82697734de882c125e3b3e4bc17; _gig_llp=facebook; _gig_llu=Baheeg; RBXEventTrackerV2=CreateDate=2/26/2016 4:01:29 AM&rbxid=96092679&browserid=4151477874; __qca=P0-1972999082-1456481070051; rbx-ip=; RBXImageCache=timg=62646533346162632D643361312D343366392D396536622D386432646561316636313662253130392E3137372E32382E32323425322F32362F3230313620393A35313A353820414D534CED27903239AA1175AB86097D565F4BC07C53; __utmt_b=1; __utma=200924205.672426321.1455730486.1456480004.1456494511.46; __utmb=200924205.4.7.1456494511; __utmc=200924205; __utmz=200924205.1456426636.42.6.utmcsr=forum.roblox.com|utmccn=(referral)|utmcmd=referral|utmcct=/Forum/ShowPost.aspx
Host:www.roblox.com
Origin:https://www.roblox.com
Referer:https://www.roblox.com/newlogin
Upgrade-Insecure-Requests:1
User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.116 Safari/537.36
Form Data
view source
view URL encoded
Username:Test
Password:Test
ReturnUrl:

0 个答案:

没有答案