2

I'm not able to login to gmail account using the following script:

$email="email@gmail.com";
$password="password";
$gacookie="";

$ch = curl_init();

$postdata="Email=$email&Passwd=$password&continue=https://www.mail.google.com";
curl_setopt ($ch, CURLOPT_URL,"https://www.gmail.com");
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
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, $gacookie);
curl_setopt ($ch, CURLOPT_COOKIEFILE, $gacookie);
curl_setopt ($ch, CURLOPT_REFERER, 'https://www.google.com');
curl_setopt ($ch, CURLOPT_POSTFIELDS, $postdata);
curl_setopt ($ch, CURLOPT_POST, 1);
$result = curl_exec ($ch);
curl_close($ch);
echo $result;<br>

Any ideas ?

j_freyre
  • 4,623
  • 2
  • 30
  • 47
Vicky
  • 171
  • 3
  • 14

2 Answers2

1

There is probably a redirect in there at which point your post data is gone.

Try adding CURLOPT_POSTREDIR => 2

Damien Overeem
  • 4,487
  • 4
  • 36
  • 55
  • 5
    Then i think we can safely assume our friends at google are doing their absolute best to stop you from using CURL to login to google :) – Damien Overeem Jan 18 '13 at 13:20
0

Try using the open inviter. Open source

http://openinviter.com

Bhavik
  • 9
  • 1
  • 7