Hello all,
I tried to use the Google AdWords API Java Classes in ColdFusion, but
encountered an error/problem I don't have an answer to yet. Here is what I
did so far.
I started with creating an refresh token and it works without any major
problems.
Afterwards I started to adapt the GetCampaigns Example from Java to
ColdFusion.
Here is the code I use:
function getCampaigns() {
// sure these fixed variables are set to the correct values in my
app... :)
var CLIENT_ID = "";
var CLIENT_SECRET = "";
var REFRESH_TOKEN = "";
var DEVELOPER_TOKEN = "";
var oAuth2Credential = createObject("java",
"com.google.api.ads.common.lib.auth.OfflineCredentials$Builder").init()
.forApi(createObject("java",
"com.google.api.ads.common.lib.auth.OfflineCredentials$Api").ADWORDS)
.withClientSecrets(CLIENT_ID,
CLIENT_SECRET)
.withRefreshToken(REFRESH_TOKEN)
.build()
.generateCredential();
// Construct an AdWordsSession.
var session = createObject("java",
"com.google.api.ads.adwords.lib.client.AdWordsSession$Builder").init()
.withOAuth2Credential(oAuth2Credential)
.withDeveloperToken(DEVELOPER_TOKEN)
.withUserAgent("TimoCom-AdWords-Scheduler") // I
have to set it | I don't know if it matters or not or what else.
.build();
var campaignService = createObject("java",
"com.google.api.ads.adwords.axis.factory.AdWordsServices").init()
.get(session, createObject("java",
"com.google.api.ads.adwords.axis.v201601.cm.CampaignServiceInterface").getClass());
var builder = createObject("java",
"com.google.api.ads.adwords.axis.utils.v201601.SelectorBuilder").init();
var CampaignField = createObject("java",
"com.google.api.ads.adwords.lib.selectorfields.v201601.cm.CampaignField");
// enum
var offset = 0;
var PAGE_SIZE = 100;
var usedCampaignFields =
javaCast("com.google.api.ads.adwords.lib.selectorfields.EntityField[]",
[CampaignField.Id, CampaignField.Name]);
var selector = builder
.fields(usedCampaignFields)
.orderAscBy(CampaignField.Name)
.offset(offset)
.limit(PAGE_SIZE)
.build();
writeDump(var=usedCampaignFields);
writeDump(var=selector);
writeDump(var=campaignService);
If I only use this code it is working, like it should. I get the
dumps(output of public information) of the variables/classes.
But when I try to get the campaigns with the following line, the
application crashes without throwing or logging the error.
var page = campaignService.get(selector).getEntries();
// or simply writeDump(campaignService.get(selector));
The error isn't handled within the onError method in our Application.cfc
nor is it logged in the Coldfusion logs nor in the Catalina Logs of Apache.
Every other Error I got previously was handled by the onError method and I
could see it and adapt my code to have it working, but not this error.
I don't know if I'm doing something wrong or it's an unhandled error in the
AdWords API, in Apache, in ColdFusion, in Java, or what is happening here.
Therefore I hope that one of you can help me.
We're using ColdFusion 9 V9,0,1,274733 on a Linux with Java V1.8.0_71.
--
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and Google+:
https://googleadsdeveloper.blogspot.com/
https://plus.google.com/+GoogleAdsDevelopers/posts
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
You received this message because you are subscribed to the Google
Groups "AdWords API Forum" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en
---
You received this message because you are subscribed to the Google Groups
"AdWords API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
Visit this group at https://groups.google.com/group/adwords-api.
To view this discussion on the web visit
https://groups.google.com/d/msgid/adwords-api/ae6cb9ab-42ff-402f-845b-bd6d6d337bf9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.