【发布时间】:2016-12-25 03:09:57
【问题描述】:
我正在尝试使用 adwords api 从我的广告系列中检索位置,我遇到了一个错误:
线程“main”java.lang.ClassCastException 中的异常:com.google.api.ads.adwords.axis.v201506.cm.Language 无法转换为 com.google.api.ads.adwords.axis.v201506。 cm.位置 在 adwords.axis.v201506.basicoperations.GetCampaigns.locationExample(GetCampaigns.java:312) 在 adwords.axis.v201506.basicoperations.GetCampaigns.main(GetCampaigns.java:86)
这是我使用 Java 的代码:
public static void locationExample(
AdWordsServices adWordsServices, AdWordsSession session, Long adGroupId) throws Exception {
CampaignCriterionServiceInterface campaignCriterionService =
adWordsServices.get(session, CampaignCriterionServiceInterface.class);
int offset = 0;
boolean morePages = true;
// Create selector.
SelectorBuilder builder = new SelectorBuilder();
Selector selector = builder
.fields(
CampaignCriterionField.Id,
CampaignCriterionField.CriteriaType,
CampaignCriterionField.LocationName)
.orderAscBy(CampaignCriterionField.Id)
.offset(offset)
.limit(PAGE_SIZE)
.build();
while (morePages) {
CampaignCriterionPage page = campaignCriterionService.get(selector);
if (page.getEntries() != null && page.getEntries().length > 0) {
for (CampaignCriterion campaignCriterionResult : page.getEntries()) {
Location location = (Location) campaignCriterionResult.getCriterion();
System.out.println("Location ID: "+location.getId());
System.out.println("Location Name: "+location.getLocationName());
System.out.println("Location Bid adjustment: ");
System.out.println("Location Type: "+location.getType());
// System.out.println("Location Reach: "+location.get);
}
} else {
System.out.println("No ad group criteria were found.");
}
offset += PAGE_SIZE;
selector = builder.increaseOffsetBy(PAGE_SIZE).build();
morePages = offset < page.getTotalNumEntries();
}
}
我的主要问题是如何从 adwords api 中检索位置和语言。
【问题讨论】:
标签: google-ads-api