有很多類似的問題,但沒有一個回答正確。從我的網站登錄gmail
問題:我的Gmail用戶名(電子郵件ID)和密碼,我想登錄使用了重定向頁面gmail.com
我試圖Gmail的:
一個。獲取源代碼(查看源代碼),並將其複製到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.
b。我試圖用cURL登錄。
我能夠使用下面的代碼獲取Gmail源。
$email = '[email protected]';
$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 = '[email protected]';
$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,是否可以登錄到Gmail,從mysite的?
我不想使用開放ID - 在這裏我需要再次輸入用戶名和密碼。我的用戶名和密碼已存儲在數據庫中(我知道這不安全)。所以我的要求是點擊鏈接時自動登錄到Gmail。
問:2.是否有可能採取採取完整的Gmail的源代碼(Gmail中的登錄頁面)(我們可以在瀏覽器的「查看源文件」看到),或者使用PHP或JavaScript或jQuery的?
cURL適合靜態頁面。 Gmail頁面充滿了JS,所以實際上,您將無法檢索完整的內容。你應該有一個上下文來運行JavaScript代碼。 – MatRt 2013-03-12 05:45:11
http://stackoverflow.com/questions/4874186/login-to-site-using-gmail同樣的問題在這裏 你正在做非常不安全的方式來實現這一點。 – chhameed 2013-03-12 05:47:53
@chhameed:我知道,我的問題是不同的,我不想公開ID – 2013-03-12 05:49:05