// Get the CampaignService.
CampaignServiceInterface campaignService =
adWordsServices.get(session, CampaignServiceInterface.class);
// Get the CustomerSyncService.
CustomerSyncServiceInterface customerSyncService =
adWordsServices.get(session, CustomerSyncServiceInterface.class);
// Get a list of all campaign IDs.
List<Long> campaignIds = new ArrayList<Long>();
Selector selector = new Selector();
selector.setFields(new String[] {"Id"});
CampaignPage campaigns = campaignService.get(selector);
if (campaigns.getEntries() != null) {
for (Campaign campaign : campaigns.getEntries()) {
campaignIds.add(campaign.getId());
}
}
// Create date time range for the past 24 hours.
DateTimeRange dateTimeRange = new DateTimeRange();
dateTimeRange.setMin(new SimpleDateFormat("yyyyMMdd HHmmss").format(new Date(System
.currentTimeMillis() - 1000L * 60 * 60 * 24)));
dateTimeRange.setMax(new SimpleDateFormat("yyyyMMdd HHmmss").format(new Date()));
// Create selector.
CustomerSyncSelector customerSyncSelector = new CustomerSyncSelector();
customerSyncSelector.setDateTimeRange(dateTimeRange);
customerSyncSelector
.setCampaignIds(ArrayUtils.toPrimitive(campaignIds.toArray(new Long[] {})));
// Get all account changes for campaign.
CustomerChangeData accountChanges = customerSyncService.get(customerSyncSelector);
// Display changes.
if (accountChanges != null && accountChanges.getChangedCampaigns() != null) {
System.out.println("Most recent change: "
+ accountChanges.getLastChangeTimestamp() + "\n");