1

この 5 つ以上の壁を一歩踏み出すたびに、楽しいだけでなくイライラすることもあると感じています。

そのため、cURL を介して Web サイトにログインしようとしていますが、多くの頭を悩ませ、Firefox 開発者ツールを使用した後、ブラウザーが JSON で応答していることがわかりました。正直なところ、JSONについては何も知りませんが、これを乗り越えれば、はっきりしているように感じます。

問題は、これらの JSON 応答を cURL でどのようにエミュレートするかです。配列にあるものをコピーして貼り付けるだけですか? この配列を各 http 要求に含めるか、それともすべて個別に行うか。

見たい場合は、JSONコードを次に示します。

__jsonp1__([{"id":"1","channel":"/meta/handshake","successful":true,"version":"1.0","supportedConnectionTypes":["long-polling","cross-origin-long-polling","callback-polling","websocket","eventsource","in-process"],"clientId":"adag3o01k7uyb0ub4s2v1h4r7fs1m3zfvp0","advice":{"reconnect":"retry","interval":0,"timeout":600000}}]);

__jsonp2__([{"id":"3","clientId":"adag3o01k7uyb0ub4s2v1h4r7fs1m3zfvp0","channel":"/meta/connect","successful":true,"advice":{"reconnect":"retry","interval":0,"timeout":600000}},{"id":"2","clientId":"adag3o01k7uyb0ub4s2v1h4r7fs1m3zfvp0","channel":"/meta/subscribe","successful":true,"subscription":"/user/11585628"}]);

__jsonp3__([{"id":"4","clientId":"adag3o01k7uyb0ub4s2v1h4r7fs1m3zfvp0","channel":"/meta/connect","successful":true,"advice":{"reconnect":"retry","interval":0,"timeout":600000}},{"channel":"/user/11585628","data":{"type":"subscribe"},"clientId":"adag3o01k7uyb0ub4s2v1h4r7fs1m3zfvp0","id":"5","authenticated":true}]);

_jsonp4__([{"id":"1","channel":"/meta/handshake","successful":true,"version":"1.0","supportedConnectionTypes":["long-polling","cross-origin-long-polling","callback-polling","websocket","eventsource","in-process"],"clientId":"uiqqkp0vf66rl0mlc8281ufknaw1qkcriu1","advice":{"reconnect":"retry","interval":0,"timeout":600000}}]);

これが私のコードです。何かを試していたので、少し奇妙に見えます

<?php


$ckfile ='   __utma=173730677.1410450142.1370766442.1370882903.1370893342.8; __utmz=173730677.1370893342.8.6.utmcsr=web.groupme.com|utmccn=(referral)|utmcmd=referral|utmcct=/groups; __utma=64278953.892306882..1370882931.1370893339.9; __utmz=64278953.1370882931.8.4.utmcsr=groupme.com|utmccn=(referral)|utmcmd=referral|utmcct=/signin; _g=%3D%3D--772097f0c6a077ac0f904c981ba5523ddffef3d5; __utmc=64278953; __utmc=173730677; __utmb=64278953.1.10.1370893339; __utmb=173730677.2.10.1370893342';

$postfields = '{"username":"@gmail.com","password":"somepass","app_id":"groupme.com","grant_type":"password"}';
$postfields2 ='{"group":{"name":"test","memberships":[]}}';
$custom = 'X-Access-Token: CEbhaIkkKTc9dtVMpxyc2IZOfnzEoh5w4UTzsVSb';

$ch2 = curl_init();
$ch3 = curl_init();

$ch = curl_init();





curl_setopt_array(
    $ch,
    array(
    CURLOPT_SSL_VERIFYPEER => false,
    CURLOPT_URL => 'https://web.groupme.com/#access_token=some token',
    CURLOPT_COOKIE=> $ckfile,
    CURLOPT_USERAGENT =>'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:21.0) Gecko/20100101 Firefox/21.0',
    CURLOPT_REFERER => 'https://groupme.com/signin',
    CURLOPT_RETURNTRANSFER => true, 
    //CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_HTTPHEADER => array('Host: web.groupme.com','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')
    )
);


curl_setopt_array(
    $ch2,
    array(
    CURLOPT_SSL_VERIFYPEER => false,
    CURLOPT_URL => 'https://web.groupme.com/#access_token=some token',
    CURLOPT_COOKIE=> $ckfile,
    CURLOPT_USERAGENT =>'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:21.0) Gecko/20100101 Firefox/21.0',
    CURLOPT_REFERER => 'https://groupme.com/signin',
    CURLOPT_RETURNTRANSFER => true, 
    //CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_HTTPHEADER => array('Host: web.groupme.com','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','Content-Type=text/html;charset=utf-8','Server=thin 1.3.1 codename Triple Espresso','Strict-Transport-Security=max-age=31536000','X-Frame-Options=sameorigin','x-xss-protection=1; mode=block','Content-Length=24275')
    )
);



$response = curl_exec($ch2);
//curl_close($ch);  



echo '<pre>';
print_r($response);
echo '</pre>'
?>
4

0 に答える 0