문제

I'm building ASP.Net MVC application and want to integrate functionnality of adwords API.

I create for that a class library in my project with those functionnality inside some classes.

In my class library I instanciate AdWordsUser like this :

var user = new AdWordsUser();

But when I use my library in my web project it don't read adwords configuration inside the web.config file.

So I tried to pass the configuration programmatically like that :

var config = new Dictionary<string, string>();

config.Add("EnableGzipCompression", "true");
config.Add("UserAgent", "xxxx");
config.Add("DeveloperToken", "xxxxx");
config.Add("ClientCustomerId", "xxxxx");
config.Add("AuthorizationMethod", "ClientLogin");
config.Add("Email", "xxxxx@xxxxxxx.xxx");
config.Add("Password", "xxxxx");

this.CurrentAdwordsUser = new AdWordsUser(config);

But it tell me that it can't convert string to bool.

does anyone know how to do ?

도움이 되었습니까?

해결책

The issue here is that AdWordsUser(headers) constructor is a deprecated header method maintained for backward compatibility from v13 API (which is mostly deprecated, but still available for developers). It takes only SOAP headers which translate into a string, no configuration parameters.

What you need is this:

this.CurrentAdwordsUser = new AdWordsUser();
(this.CurrentAdwordsUser.Config as AdWordsAppConfig).EnableGzipCompression = true;

Do similarly for any other configuration setting.

Btw, you may want to post any followup questions 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

Cheers, Anash

다른 팁

I think the issue may be that you are passing "true" instead of True. If you believe this is a bug you can open an issue here: http://code.google.com/p/google-api-adwords-dotnet/issues/list

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top