adWordsServices.get(session, VideoTargetingGroupCriterionServiceInterface.class);
int offset = 0;
// Create selector.
TargetingGroupCriterionSelector selector = new TargetingGroupCriterionSelector();
selector.setCampaignIds(new long[] {campaignId});
selector.setCriterionTypes(new BaseCriterionType[] {BaseCriterionType.KEYWORD});
// Display network keywords.
selector.setCriteriaDimension(CriteriaDimension.KEYWORD);
selector.setPaging(new Paging(offset, PAGE_SIZE));
TargetingGroupCriterionPage page;
do {
// Get all keywords.
page = videoTargetingGroupCriterionService.get(selector);
// Display keywords.
if (page.getEntries() != null) {
for (TargetingGroupCriterion targetingGroupCriterion : page.getEntries()) {
String negative = (targetingGroupCriterion instanceof NegativeTargetingGroupCriterion)
? " (negative)"
: "";
BaseKeyword keyword = (BaseKeyword) targetingGroupCriterion.getCriterion();
System.out.printf("Criterion%s id %d, targeting group id %d, "
+ "and text '%s' was found.%n",
negative,
keyword.getId(),
targetingGroupCriterion.getTargetingGroupId(),
keyword.getText());
}
} else {
System.out.println("No keywords were found.");
}
offset += PAGE_SIZE;
selector.getPaging().setStartIndex(offset);
} while (offset < page.getTotalNumEntries());
}