Jump to content

Recommended Posts

<?php>

$login = "https://www.google.com/accounts/ServiceLoginAuth?service=mail";

 

$c = curl_init();

curl_setopt($c, CURLOPT_URL, $login);

curl_setopt($c, CURLOPT_COOKIEJAR, "cookies.txt");

curl_setopt($c, CURLOPT_COOKIEFILE, "cookies.txt");

curl_setopt($c, CURLOPT_POST, 1);

curl_setopt($c, CURLOPT_POSTFIELDS, "username=myusername&password=mypassword");

 

curl_setopt($c, CURLOPT_RANGE, "0-4096");

curl_setopt($c, CURLOPT_RETURNTRANSFER, 1); // return to var

curl_setopt($c, CURLOPT_FAILONERROR, 1); // dont hang

curl_setopt($c, CURLOPT_FOLLOWLOCATION, 1); // allow redirects

curl_setopt($c, CURLOPT_TIMEOUT, 3); // time out after 3s

curl_setopt($c, CURLOPT_HEADER, 0);

$login_done = curl_exec($c);

 

?>

 

 

 

i want to login to gmail using curl php. the code works for some other account; But i m not able to use it for gmail  . I want to see the inbox. that is after logging in thru this

Link to comment
https://forums.phpfreaks.com/topic/158009-php-curl-function-help-please/
Share on other sites

<?php>
$login = "https://www.google.com/accounts/ServiceLoginAuth?service=mail";

$c = curl_init();
curl_setopt($c, CURLOPT_URL, $login);
curl_setopt($c, CURLOPT_COOKIEJAR, "cookies.txt");
curl_setopt($c, CURLOPT_COOKIEFILE, "cookies.txt");
curl_setopt($c, CURLOPT_POST, 1);
curl_setopt($c, CURLOPT_POSTFIELDS, "username=myusername&password=mypassword");

curl_setopt($c, CURLOPT_RANGE, "0-4096");
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1); // return to var
curl_setopt($c, CURLOPT_FAILONERROR, 1); // dont hang
curl_setopt($c, CURLOPT_FOLLOWLOCATION, 1); // allow redirects
curl_setopt($c, CURLOPT_TIMEOUT, 3); // time out after 3s
curl_setopt($c, CURLOPT_HEADER, 0);
$login_done = curl_exec($c);

?>

 

 

all i get is a blank page after that,  when clicked. But i tried  a different URL and it works that time. But for gmail it is not working. can anyone tell me what is wrong with this code

<?php>
$login = "https://www.google.com/accounts/ServiceLoginAuth?service=mail";

$c = curl_init();
curl_setopt($c, CURLOPT_URL, $login);
curl_setopt($c, CURLOPT_COOKIEJAR, "cookies.txt");
curl_setopt($c, CURLOPT_COOKIEFILE, "cookies.txt");
curl_setopt($c, CURLOPT_POST, 1);
curl_setopt($c, CURLOPT_POSTFIELDS, "Email='ppradeepkumar2006'&
								 Passwd='puppyhead'&
								 continue='http://mail.google.com/mail/?ui=html&zy=l'&
								 service='mail'&
								 rm='false'&
								 ltmpl='false'&
								 h1='en'&
								 ltmpl='default'&
								 scc='1'&
								 GALX='8eKZr_QRh9E'");

curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($c, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($c, CURLOPT_URL, $url);
curl_setopt($c, CURLOPT_RANGE, "0-4096");
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1); // return to var
curl_setopt($c, CURLOPT_FAILONERROR, 1); // dont hang
curl_setopt($c, CURLOPT_FOLLOWLOCATION, 1); // allow redirects
curl_setopt($c, CURLOPT_TIMEOUT, 3); // time out after 3s
curl_setopt($c, CURLOPT_HEADER, 0);
$login_done = curl_exec($c);

echo $login_done; 
?>

 

 

i tried to find the fields in gmail's source HTML file..i added the fields whichever was missing. but still im not able to pass thru

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.