2011-06-03 72 views
-1

我想連接我的Google帳戶並獲取我的博主主頁的html代碼。我發現需要一個cookie來保持連接,但我不知道如何做到這一點。Visual C#:連接到Google帳戶

的郵政通訊地址作爲用戶名和傳球是「https://www.google.com/accounts/ClientLogin」提前

謝謝!

回答

1

試試這個

private bool Authorize(out string authCode) 
{ 
    bool result = false; 
    authCode = ""; 

    string queryString = String.Format("https://www.google.com/accounts/ClientLogin?accountType=HOSTED_OR_GOOGLE&Email={0}&Passwd={1}&service=cloudprint&source={2}", UserName, Password, Source); 
    HttpWebRequest request = (HttpWebRequest)WebRequest.Create(queryString); 

    HttpWebResponse response = (HttpWebResponse)request.GetResponse(); 
    string responseContent = new StreamReader(response.GetResponseStream()).ReadToEnd(); 

    string[] split = responseContent.Split('\n'); 
    foreach (string s in split) 
    { 
     string[] nvsplit = s.Split('='); 
     if (nvsplit.Length == 2) 
     { 
      if (nvsplit[0] == "Auth") 
      { 
       authCode = nvsplit[1]; 
       result = true; 
      } 
     } 
    } 

    return result; 
} 

`

+0

emmm結果是SID LSID和AUTH,但我如何才能獲得 「HTML代碼」? – Misha 2011-06-03 12:56:51

+1

http://code.google.com/apis/blogger/docs/2.0/developers_guide_dotnet.html#RetrievingWithoutQuery – Craig 2011-06-03 13:11:12