开发者

Getting started with Google Adword .net API

Most things that I've found about the .net AdWords API mention creating a bunch of settings for the application that will be used when you create an instance of the AdWordsUser class; however, I've had no luck with this. My user always ends up nil and no settings are being read even though I named them as indicated in the AdWordsAppConfig class.

AdWordsAppConfig appConfig = new AdWordsAppConfig();
appConfig.AdWordsApiServer = "https://adwords-sandbox.google.com";
appConfig.Email = "fname.lname@gmail.com";
appConfig.Password = "password";
appConfig.DeveloperToken = "fname.lname@gmail.com++USD";

AdWordsUser user = new AdWordsUser();

The AdWordsUser has an overloaded constructor that accepts a dictionary of strings containing configuration parameters but doesn't have on that accepts an AdWordsAppConfig object.

http://code.google.com/p/google-api-adwords-dotnet/source/browse/trunk/src/AdWords/Lib/AdWordsAppConfig.cs

According to the AdWordsAppConfig class the following is used to retreive the settings when you call the constructor; however, how do you create a section called "AdWordsApi" in the App.Con开发者_高级运维fig? I don't see that option in the settings editor.

ReadSettings((Hashtable) ConfigurationManager.GetSection("AdWordsApi"));

Any ideas on the proper way to set the configuration information and create the user instance that I need?


What Eric mentioned is the long-term solution, but if anyone is looking for a quick answer, this is how you do it:

AdWordsUser user = new AdWordsUser();
(user.Config as AdWordsAppConfig).Password = "XXXXX";
//TODO (Add more configuration settings here.

CampaignService campaignService = (CampaignService) user.GetService(AdWordsService.v201109.CampaignService);
//TODO (Add your code here to use the service.)

Cheers, Anash


You may want to post this question on the official AdWords API forum, as it is monitored by the current maintainers of that library:

http://code.google.com/apis/adwords/forum.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜