我正在尝试在此帖子后面调用Google AnalyticsAPI: Google Analytics API - Programmatically fetch page views in server side
到目前为止,这是我的代码:
WebClient webClient = new WebClient();
NameValueCollection data = new NameValueCollection();
data.Add("accountType", "GOOGLE");
data.Add("Email", "email@company.com");
data.Add("Passwd", "password!");//Passwd, not a misspell.
data.Add("service", "analytics");
byte[] bytes = webClient.UploadValues(new Uri("https://www.google.com/accounts/ClientLogin"), "POST", data);
string tokens = Encoding.UTF8.GetString(bytes);
string authToken = extractAuthToken(tokens);
但是,我在webClient.UploadValues上收到错误:远程服务器返回错误:(404)Not Found。
答案 0 :(得分:0)
您应该使用Oauth2,请参阅https://developers.google.com/api-client-library/java/google-api-java-client/oauth2
ClientLogin自2012年4月20日起已被弃用,请参阅:https://developers.google.com/identity/protocols/AuthForInstalledApps