2011-05-04 34 views

回答

2

看看以下頁面:

http://code.google.com/googleapps/domain/email_settings/developers_guide_protocol.html#GA_email_settings_api_auth

你基本上通過發佈此URL,以獲得身份驗證令牌:

https://www.google.com/accounts/ClientLogin 

發佈數據格式必須爲如下:

&Email=<email_address>&Passwd=<password>&accountType=HOSTED&service=apps 

Pete

+0

我覺得這個API只適用於谷歌賬戶管理員。我需要對我的個人Gmail帳戶進行身份驗證。無論如何,我試圖獲得這個令牌,但我收到'403禁止'的錯誤。 – anth 2011-12-09 18:05:19

+0

這聽起來像你沒有發佈數據,但正在嘗試通過url傳遞參數。看看這段代碼,它應該有所幫助:http://stackoverflow.com/questions/304337/post-data-to-a-php-page-from-c-sharp-winform – 2011-12-09 20:46:28

+0

我在做類似的事情方式http://codepaste.net/shtyac沒有成功。我在request.GetResponse()上收到WebException(403)。 – anth 2011-12-10 09:40:05

0

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()); 
       } 
      } 
     } 
相關問題