I'm trying to access Google Adwords Sandbox API and I cannot, for the life of me, figure out what's going on.
Here's my code:
var wsUrl = "https://adwords-sandbox.google.com/api/adwords/cm/v201008/CampaignService";
var soapRequest =
'<soapenv:Envelope \
xmlns:soapenv="http://schemax.xmlsoap.org/soap/envelope/" \
xmlns="https://adwords.google.com/api/adwords/cm/v200906"> \
<soapenv:Header> \
<service&g开发者_开发百科t;adwords</service> \
<email>***@gmail.com</email> \
<password>***</password> \
<developerToken>***@gmail.com++USD</developerToken> \
<useragent>MyApplication</useragent> \
</soapenv:Header> \
<soapenv:Body> \
<getClientAccounts/> \
</soapenv:Body> \
</soapenv:Envelope>';
$.ajax({
type: "GET",
url: wsUrl,
contentType: document.body,
crossDomain: true,
dataType: "jsonp",
data: soapRequest,
success: processSuccess,
error: processError
});
});
function processSuccess(data, status, req) {
if (status == "success")
console.log("success");
}
function processError(data, status, req) {
console.log("status = " + status + " data= " + data );
}
I keep getting 500 Internal Server errors. What am I doing wrong?! On the Google Adwords Sandbox website, they list simple instructions:
To create a sandbox account, send a get request to the sandbox version of CampaignService, using the WSDL location and sandbox headers as described below. This initial call to the sandbox creates an MCC sandbox account, along with five client accounts, for the email address you specified. Your sandbox account and its client accounts start out empty. http://code.google.com/apis/adwords/docs/sandbox.html
Help!
AdWords API is a SOAP API, so sending the data as JSONP won't work. Also, $.ajax with cross-domain=true works only for JSON or JSONP variants, anything other than that will be stopped by the cross-domain policies of your browser.
You can try exploring the AdWords API Javascript client library instead - see http://code.google.com/p/google-api-adwords-js/ for details.
Our primary discussion forum is at http://groups.google.com/group/adwords-api?pli=1, and I frequently answer developer questions there, so if you have any followup questions, feel free to ask there and I'll be happy to answer your questions.
Cheers, Anash P. Oommen
精彩评论