有很多类似的问题,但没有一个能正确回答。
问题:我有 gmail 用户名(电子邮件 ID)和密码,我想登录 gmail 而不将页面重定向到 gmail.com
我试过了 :
一个。获取源代码(从浏览器查看源代码),并将其复制到 html 页面中,onload 我在此表单中添加了用户名和密码,并使用 javascript => 提交了此页面它工作正常。
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.
湾。我尝试使用 cURL 登录。
我能够使用以下代码获取 gmail 提要。
$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);
但是,当累了登录https://accounts.google.com/ServiceLogin
它的代码时不会登录。
$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);
问题: 1. 是否可以从 mysite 登录到 gmail?
我不想使用开放 ID - 这里我需要再次输入用户名和密码。我的用户名和密码已经存储在数据库中(我知道这不安全。)。所以我的要求是在单击链接时自动登录到 gmail。
问题: 2. 是否可以使用 php 或 javascript 或 jQuery 获取 gmail 的完整(我们可以在浏览器“查看源代码”中看到)源代码(gmail 的登录页面)?