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

---------

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

From: cumcum 82 <cumcum82_at_gmail.com>
Date: Mon, 26 Jan 2009 04:37:37 +0200
Message-ID: <f1e7268b0901251837x6effaa8ev541da47d9bb72189@mail.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
Received on Mon 26 Jan 2009 - 03:30:44 EET

---------

Bu arsiv hypermail 2.2.0 tarafindan uretilmistir.