我正在开发一些 C# 项目以对Adwords进行 API 调用以下载数据。
我已经通过以下方式获得了访问令牌:
WebRequest webRequest = HttpWebRequest.Create("https://www.google.com/accounts/ClientLogin");
webRequest.Method = "POST";
webRequest.ContentType = "application/x-www-form-urlencoded";
string postParams =
"accountType=" + HttpUtility.UrlEncode("GOOGLE") +
"&Email=" + HttpUtility.UrlEncode("xxxx@xxxx.com") +
"&Passwd=" + HttpUtility.UrlEncode("xxxx") +
"&service=" + HttpUtility.UrlEncode("adwords") +
"&source=" + HttpUtility.UrlEncode(string.Format("{0}-{1}-{2}", "sample1",
"sample2", "1"));
byte[] postBytes = Encoding.UTF8.GetBytes(postParams);
webRequest.ContentLength = postBytes.Length;
using (Stream strmReq = webRequest.GetRequestStream())
{
strmReq.Write(postBytes, 0, postBytes.Length);
}
string retVal = "";
try
{
WebResponse response = webRequest.GetResponse();
using (StreamReader reader = new StreamReader(response.GetResponseStream()))
{
string sResponse = reader.ReadToEnd();
string[] splits = sResponse.Split('\n');
foreach (string split in splits)
{
string[] subsplits = split.Split('=');
if (subsplits.Length >= 2 && subsplits[0] == "Auth")
{
retVal = subsplits[1];
}
}
}
}
catch (WebException ex)
{
throw new ApplicationException("Could not generate auth token.", ex);
}
如果有人可以让我知道进行 API 调用以下载数据的下一步是什么,我将不胜感激。https://developers.google.com/adwords/api/docs/guides/reporting
谢谢。