I am working on some C# project to make API calls to Adwords to download data.
I have already get the access token by using:
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("[email protected]") +
"&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);
}
I would appreciate if someone can let me know what is the next step to make an API call to download data. https://developers.google.com/adwords/api/docs/guides/reporting
Thanks.