如何從Gmail的最後帳戶活動頁面獲取數據:Gmail的最後活動
此信息可在地址:https://mail.google.com/mail/?ui=2&ik=SOME_ACCOUNT_ID&view=ac
問題是我不知道如何驗證以訪問此頁面。我想我應該使用OAuth協議,但不知道細節。
我想用C#
有沒有人有一些提示?
如何從Gmail的最後帳戶活動頁面獲取數據:Gmail的最後活動
此信息可在地址:https://mail.google.com/mail/?ui=2&ik=SOME_ACCOUNT_ID&view=ac
問題是我不知道如何驗證以訪問此頁面。我想我應該使用OAuth協議,但不知道細節。
我想用C#
有沒有人有一些提示?
看看以下頁面:
你基本上通過發佈此URL,以獲得身份驗證令牌:
https://www.google.com/accounts/ClientLogin
發佈數據格式必須爲如下:
&Email=<email_address>&Passwd=<password>&accountType=HOSTED&service=apps
Pete
https://mail.google.com/mail/?ui=2&ik=SOME_ACCOUNT_ID&view=ac現在不工作?我得到一些JavaScript代碼。 我的代碼:
string URL1 = "https://mail.google.com/mail/";
string clientID = "my_client_id";
string httpBody1 =
string.Format(
"ui=2&ik={0}&view=ac",
clientID);
var request1 = WebRequest.Create(URL1) as HttpWebRequest;
request1.ContentType = "application/x-www-form-urlencoded";
request1.Method = "POST";
using (var streamWriter1 = new StreamWriter(request1.GetRequestStream()))
{
streamWriter1.Write(httpBody);
}
using (HttpWebResponse httpWebResponse1 = request1.GetResponse() as HttpWebResponse)
{
if (httpWebResponse1.StatusCode == HttpStatusCode.OK)
{
using (Stream stream1 = httpWebResponse1.GetResponseStream())
{
StreamReader readStream1 = new StreamReader(stream1, Encoding.UTF8);
Console.Out.WriteLine(readStream1.ReadToEnd());
}
}
}
我覺得這個API只適用於谷歌賬戶管理員。我需要對我的個人Gmail帳戶進行身份驗證。無論如何,我試圖獲得這個令牌,但我收到'403禁止'的錯誤。 – anth 2011-12-09 18:05:19
這聽起來像你沒有發佈數據,但正在嘗試通過url傳遞參數。看看這段代碼,它應該有所幫助:http://stackoverflow.com/questions/304337/post-data-to-a-php-page-from-c-sharp-winform – 2011-12-09 20:46:28
我在做類似的事情方式http://codepaste.net/shtyac沒有成功。我在request.GetResponse()上收到WebException(403)。 – anth 2011-12-10 09:40:05