// Create a feed that will sync to the Google Places account specified
// by placesEmailAddress. Do not add FeedAttributes to this object,
// as AdWords will add them automatically because this will be a
// system generated feed.
Feed placesFeed = new Feed();
placesFeed.setName("Places feed #" + System.currentTimeMillis());
PlacesLocationFeedData feedData = new PlacesLocationFeedData();
feedData.setEmailAddress(placesEmailAddress);
OAuthInfo oAuthInfo = new OAuthInfo();
oAuthInfo.setHttpMethod("GET");
oAuthInfo.setHttpRequestUrl("https://www.google.com/local/add");
oAuthInfo.setHttpAuthorizationHeader(String.format("Bearer %s", placesAccessToken));
feedData.setOAuthInfo(oAuthInfo);
placesFeed.setSystemFeedGenerationData(feedData);
// Since this feed's feed items will be managed by AdWords,
// you must set its origin to ADWORDS.
placesFeed.setOrigin(FeedOrigin.ADWORDS);
// Create an operation to add the feed.
FeedOperation feedOperation = new FeedOperation();
feedOperation.setOperand(placesFeed);
feedOperation.setOperator(Operator.ADD);
// Add the feed. Since it is a system generated feed, AdWords will automatically:
// 1. Set up the FeedAttributes on the feed.
// 2. Set up a FeedMapping that associates the FeedAttributes of the feed
// with the placeholder fields of the LOCATION placeholder type.
FeedReturnValue addFeedResult = feedService.mutate(new FeedOperation[] {feedOperation});
Feed addedFeed = addFeedResult.getValue(0);
System.out.printf("Added places feed with ID %d%n", addedFeed.getId());
// Add a CustomerFeed that associates the feed with this customer for
// the LOCATION placeholder type.
CustomerFeed customerFeed = new CustomerFeed();
customerFeed.setFeedId(addedFeed.getId());
customerFeed.setPlaceholderTypes(new int[] {PLACEHOLDER_LOCATION});
// Create a matching function that will always evaluate to true.
Function customerMatchingFunction = new Function();
ConstantOperand constOperand = new ConstantOperand();