}
public static void runExample(
AdWordsServices adWordsServices, AdWordsSession session, Long campaignId) throws Exception {
// Get the CampaignAdExtensionService.
CampaignAdExtensionServiceInterface campaignAdExtensionService =
adWordsServices.get(session, CampaignAdExtensionServiceInterface.class);
// Get the GeoLocationService.
GeoLocationServiceInterface geoLocationService =
adWordsServices.get(session, GeoLocationServiceInterface.class);
// Create address.
Address address = new Address();
address.setStreetAddress("1600 Amphitheatre Parkway");
address.setCityName("Mountain View");
address.setProvinceCode("US-CA");
address.setPostalCode("94043");
address.setCountryCode("US");
// Create geo location selector.
GeoLocationSelector selector = new GeoLocationSelector();
selector.setAddresses(new Address[] {address});
// Get geo location.
GeoLocation[] geoLocationResult = geoLocationService.get(selector);
GeoLocation geoLocation = geoLocationResult[0];
// Create location extension.
LocationExtension locationExtension = new LocationExtension();
locationExtension.setAddress(geoLocation.getAddress());
locationExtension.setGeoPoint(geoLocation.getGeoPoint());
locationExtension.setEncodedLocation(geoLocation.getEncodedLocation());
locationExtension.setSource(LocationExtensionSource.ADWORDS_FRONTEND);
// You can optionally provide these field(s).
locationExtension.setCompanyName("Google");
locationExtension.setPhoneNumber("650-253-0000");
// Create campaign ad extension.
CampaignAdExtension campaignAdExtension = new CampaignAdExtension();
campaignAdExtension.setCampaignId(campaignId);
campaignAdExtension.setAdExtension(locationExtension);
// Create operations.
CampaignAdExtensionOperation operation = new CampaignAdExtensionOperation();
operation.setOperand(campaignAdExtension);
operation.setOperator(Operator.ADD);
CampaignAdExtensionOperation[] operations = new CampaignAdExtensionOperation[] {operation};
// Add campaign ad extension.
CampaignAdExtensionReturnValue result = campaignAdExtensionService.mutate(operations);
// Display campaign ad extensions.
for (CampaignAdExtension campaignAdExtensionResult : result.getValue()) {
System.out.println("Location campaign ad extension with campaign id \""
+ campaignAdExtensionResult.getCampaignId() + "\", ad extension id \""