我正在尝试直接登录 Google Analytics。解释一下,我有一个帐户系统,我希望当您选择一个 ASP.NET 按钮时,它会通过静默登录将您重定向到指定的 Google Analytics 帐户。
我已经仔细研究了 Dave Cullen 的 ASP.NET 库,虽然我可以使用 HttpWebRequest“静默”登录,但我无法将用户留在该页面上。我也有各种带有“无法发送具有这种动词类型的内容主体”错误的戏剧。
这是我目前基于 Dave 库的非常基本的代码;
string token = GoogleAnalytics.getSessionTokenClientLogin(username, password);
NameValueCollection profiles = GoogleAnalytics.getAccountInfo(token, GoogleAnalytics.mode.ClientLogin);
HttpWebRequest theRequest = (HttpWebRequest)WebRequest.Create("https://www.google.com/analytics/settings/?et=reset&hl=en_uk&et=reset&hl=en-US&et=reset&hl=en-GB");
theRequest.Headers.Add("Authorization: GoogleLogin auth=" + token);
Stream responseBody = theRequest.GetRequestStream();
Encoding encode = System.Text.Encoding.GetEncoding("utf-8");
StreamReader readStream = new StreamReader(responseBody, encode);
因此,我的问题是;1.这个可以吗?2.这甚至是正确的方法吗?
欢迎咨询!