[Linux-programlama] Re: Curl ile Gmail login - 302 Hatası

---------

[Linux-programlama] Re: Curl ile Gmail login - 302 Hatası

From: Elvin Åžiriyev <elvin_at_siriyev.net>
Date: Mon, 26 Jan 2009 09:42:46 +0200
Message-ID: <ded068c00901252342r764a2d31o903dd509e58f5cee@mail.gmail.com>

Bu birzamanlar işe yarıyordu. uğraşman gerekmeyebilir:
http://gmail-lite.sourceforge.net/wordpress/index.php/about/libgmailer/

2009/1/26 cumcum 82 <cumcum82_at_gmail.com>

> Merhaba;
> Curl kullanarak gmaile login olma çabasındayım. chmod 777 olarak
> /var/www dizini altında cookies.txt dosyamı hazırladım. Kodu yazdım
> ancak headerdan okuduğuma göre 302 hatası alıyorum ve gmail beni login
> sayfasına geri gönderiyor. Cookieler ile ilgili birşeyi atlıyorum ama
> bulamadım yardımınızı rica ediyorum. Kodum şöyle:
>
> <?php
>
> $url = "http://mail.google.com/mail/x/";
> $page = file_get_contents($url);
> preg_match_all('/<input type=\"hidden\"
> name=\"([^"]+)\".*?value=\"([^"]*)\"[^>]*>/is', $page, $matches,
> PREG_SET_ORDER);
> $num = (count($matches)-1);
>
> for($i = "0"; $i <= $num; $i++) {
> $post .= urlencode($matches[$i][1]) . "=" . urlencode($matches[$i][2]) .
> "&";
> }
>
> $remove = array("amp%3B" => "");
> $continue = strtr(urlencode($matches[1][2]), $remove);
> $posts = strtr($post, $remove);
> $user_agent = "NokiaE50-1/3.0 (06.27.1.0) SymbianOS/9.1 Series60/3.0
> Profile/MIDP-2.0 Configuration/CLD-1.1";
> $email = "cumcum82%40gmail.com";
> $pass = "XXXXXXXX";
> $action = "https://www.google.com/accounts/ServiceLoginAuth?service=mail
> ";
> $referer = "
> https://www.google.com/accounts/ServiceLogin?service=mail&passive=true&rm=false&continue=
> "
> . $continue . "&bsv=1k96igf4806cy&ltmpl=ecobx&nui=5&btmpl=mobile";
> $cookie = "/var/www/cookies.txt";
> $post_fields = $posts .
>
> "Email=$email&Passwd=$pass&PersistentCookie=yes&rmShown=1&signIn=Sign%20in";
>
> $ch = curl_init();
>
> curl_setopt($ch, CURLOPT_URL, $action);
> curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);
> curl_setopt($ch, CURLOPT_REFERER, $referer);
> curl_setopt($ch, CURLOPT_HTTPHEADER, Array("Content-Type:
> application/x-www-form-urlencoded"));
> curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
>
> curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
> curl_setopt($ch, CURLOPT_HEADER, 1);
> curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
>
> curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
> curl_setopt($ch, CURLOPT_POST, 1);
>
> curl_setopt($ch, CURLOPT_POSTFIELDS, $post_fields);
> curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie);
> curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie);
> $result = curl_exec($ch);
> curl_close($ch);
>
> echo $result;
>
> ?>
>
> Zaman ayıran herkese şimdiden teşekkür.
> _______________________________________________
> Linux-programlama mailing list
> Linux-programlama_at_liste.linux.org.tr
> http://liste.linux.org.tr/mailman/listinfo/linux-programlama
>

-- 
Elvin Åžiriyev
http://siriyev.net

_______________________________________________
Linux-programlama mailing list
Linux-programlama_at_liste.linux.org.tr
http://liste.linux.org.tr/mailman/listinfo/linux-programlama
Received on Mon 26 Jan 2009 - 08:35:54 EET

---------

Bu arsiv hypermail 2.2.0 tarafindan uretilmistir.