There are lot of similar questions, but none of them answered properly.
Issue : I have gmail username(email id) and password, I want to login to gmail with out redirecting the page to gmail.com
I tried :
a. Fetched the source code (View source from browser), and copied it in a html page, onload I added username and password to this form and submitted this page with javascript => It works fine.
But, I need to fetch the source dynamically, using PHP.
So, I tried with `file_get_contents` => Here I am not able to get full source code some of the js code and some hidden fields are missing => When I tired to login with this code, it is not logging in, it simply redirects to gmail.com login page.
Then I tried to get the source code using cURL, This also gave me incomplete source, and I am not able to login.
b. I tried to login using cURL.
I was able to get the gmail feed using following code.
$email = 'username@gmail.com';
$password = 'password';
$curl = curl_init('https://mail.google.com/mail/feed/atom');
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_USERPWD, $email.':'.$password);
echo $content = curl_exec($curl);
But, When tired the code to login to https://accounts.google.com/ServiceLogin it is not loging in.
$email = 'username@gmail.com';
$password = 'password';
$curl = curl_init('https://accounts.google.com/ServiceLogin');
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_USERPWD, $email.':'.$password);
echo $content = curl_exec($curl);
Question : 1. Is it possible to login to gmail, from mysite ?
I don't want to use open ID - Here I need to enter username and password again. My username and password in already stored in DB (I know this is not secure.). So my requirement is while clicking a link automatically login to gmail.
Question : 2. Is it possible to take take the complete (Which we can see in browser "view source") source code of gmail(Login page of gmail), either using php or javascript or jQuery ?