public static void main(String[] args) throws Exception {
// Generate a refreshable OAuth2 credential similar to a ClientLogin token
// and can be used in place of a service account.
Credential oAuth2Credential = new OfflineCredentials.Builder()
.forApi(OfflineCredentials.Api.ADWORDS)
.withClientSecrets(Client_ID, Client_secret).withRefreshToken(RefreshToken)
.build()
.generateCredential();
// Construct an AdWordsSession.
AdWordsSession session = new AdWordsSession.Builder()
.withClientCustomerId(clientCustomerId).withDeveloperToken(developerToken).withUserAgent(userAgent)
.withOAuth2Credential(oAuth2Credential)
.build();
AdWordsServices adWordsServices = new AdWordsServices();
runExample(adWordsServices, session);
}
public static void runExample(
AdWordsServices adWordsServices, AdWordsSession session) throws Exception {
// Get the CampaignService.
DataService dataService = adWordsServices.get(session, DataService.class);
int offset = 0;
// Create selector.
SelectorBuilder builder = new SelectorBuilder();
Selector selector = builder
.fields("AdGroupId", "Bid", "CampaignId", "CriterionId", "EndDate", "LocalClicks", "LocalCost", "LocalImpressions", "PromotedImpressions", "StartDate")
.build();
AdGroupBidLandscapePage page = null;
do {
// Get all data
page = dataService.getAdGroupBidLandscape(selector); // the problem is here : get method isn't recognized
// Display campaigns.
if (page.getEntries() != null) {
for ( DataService ds : page.getEntries()) {
System.out.println(ds.toString());
}
} else {
System.out.println("No campaigns were found.");
}
offset += PAGE_SIZE;
selector = builder.increaseOffsetBy(PAGE_SIZE).build();
} while (offset < page.getTotalNumEntries());
}