2011-06-03 38 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