4 messages in com.googlegroups.adwords-apiAdWords API switching between live an...| From | Sent On | Attachments |
|---|---|---|
| David | 29 Jul 2008 07:54 | |
| AdWords API Advisor | 29 Jul 2008 11:51 | |
| David | 29 Jul 2008 12:12 | |
| AdWords API Advisor | 01 Aug 2008 09:28 |
| Subject: | AdWords API switching between live and sandbox - something I don't understand![]() |
|---|---|
| From: | David (cont...@akamarketing.com) |
| Date: | 07/29/2008 07:54:23 AM |
| List: | com.googlegroups.adwords-api |
Hi read a previous message on this group about switching between the two different evironments G offter to adwords api developers. I want code whereby I can either set a param on a getService(string servicetype, bool sandbox) type of method or overall via the web.config. I have different config sections in web.config for live and sandbox and the changing off the values for sandbox v live is going fine. In fact so too is the changing of the .URL property on my new created services, but I just don't understand why...
Here's some code I written
//are we using the sandbox or live API environment? if(sandbox){environment = "adwordsSandbox";} else{environment = "adwordsLive";}
Hashtable headers = (Hashtable)ConfigurationManager.GetSection(environment); if (headers != null && headers.Count == 5) //the section a) must be there { //and b) must have exactly 5 values email = headers["email"].ToString(); password = headers["password"].ToString(); useragent = headers["useragent"].ToString(); applicationToken = headers["applicationToken"].ToString(); developerToken = headers["developerToken"].ToString(); } else { //throw an error if the section is missing or malformed throw new Exception("The \"" + environment + "\" configuration section in the web.config file is missing or incorrectly formed. It must have five elements: email, password, useragent, applicationToken and developerToken to be considered well formed."); }
//create the appropriate service based on the serviceTypes enum passed in if(serviceTypes == ServiceTypes.Account) { AccountService service = new AccountService(); //HERE I'm creating a sandbox object??? if(sandbox) {service.Url = "https://sandbox.google.com/api/adwords/v12/ AccountService";} else{ service.Url = "https://adwords.google.com/api/ adwords/v12/AccountService";}
What I don't understand is how this works, I mean why did I first have to create an instance of anything? I added a web reference to to the SANDBOX campaign wsdl file via visual studio, I placed a using com.google.sandbox statement at the top of my file so when I call AccountService service = new AccountService() in the above code Im creating a sandbox object? but yet by changing its URL it effectively become a LIVE object.
Do I need to add web references for all the services I need to use or can I simple create a false AccountService() even if I want campaignservice() and just change the URL.
Anyone shed any light on this.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"AdWords API Forum" group.
To post to this group, send email to adwo...@googlegroups.com
To unsubscribe from this group, send email to
adwo...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en
-~----------~----~----~----~------~----~------~--~---




