use of com.google.api.ads.adwords.axis.v201809.cm.FeedItemReturnValue in project googleads-java-lib by googleads.
the class AddSiteLinksUsingFeeds method createSiteLinksFeedItems.
private static void createSiteLinksFeedItems(AdWordsServicesInterface adWordsServices, AdWordsSession session, SiteLinksDataHolder siteLinksData) throws RemoteException {
// Get the FeedItemService.
FeedItemServiceInterface feedItemService = adWordsServices.get(session, FeedItemServiceInterface.class);
// Create operations to add FeedItems.
FeedItemOperation home = newSiteLinkFeedItemAddOperation(siteLinksData, "Home", "http://www.example.com", "Home line 2", "Home line 3");
FeedItemOperation stores = newSiteLinkFeedItemAddOperation(siteLinksData, "Stores", "http://www.example.com/stores", "Stores line 2", "Stores line 3");
FeedItemOperation onSale = newSiteLinkFeedItemAddOperation(siteLinksData, "On Sale", "http://www.example.com/sale", "On Sale line 2", "On Sale line 3");
FeedItemOperation support = newSiteLinkFeedItemAddOperation(siteLinksData, "Support", "http://www.example.com/support", "Support line 2", "Support line 3");
FeedItemOperation products = newSiteLinkFeedItemAddOperation(siteLinksData, "Products", "http://www.example.com/prods", "Products line 2", "Products line 3");
// This site link is using geographical targeting to use LOCATION_OF_PRESENCE.
FeedItemOperation aboutUs = newSiteLinkFeedItemAddOperation(siteLinksData, "About Us", "http://www.example.com/about", "About Us line 2", "About Us line 3", true);
FeedItemOperation[] operations = new FeedItemOperation[] { home, stores, onSale, support, products, aboutUs };
FeedItemReturnValue result = feedItemService.mutate(operations);
for (FeedItem item : result.getValue()) {
System.out.printf("FeedItem with feedItemId %d was added.%n", item.getFeedItemId());
siteLinksData.siteLinkFeedItemIds.add(item.getFeedItemId());
}
// Target the "aboutUs" sitelink to geographically target California.
// See https://developers.google.com/adwords/api/docs/appendix/geotargeting for
// location criteria for supported locations.
restrictFeedItemToGeoTarget(adWordsServices, session, result.getValue(5), 21137L);
}
use of com.google.api.ads.adwords.axis.v201809.cm.FeedItemReturnValue in project googleads-java-lib by googleads.
the class AddAdCustomizer method createCustomizerFeedItems.
/**
* Creates FeedItems with the values to use in ad customizations for each ad group in
* <code>adGroupIds</code>.
*/
private static void createCustomizerFeedItems(AdWordsServicesInterface adWordsServices, AdWordsSession session, List<Long> adGroupIds, AdCustomizerFeed adCustomizerFeed) throws RemoteException {
// Get the FeedItemService.
FeedItemServiceInterface feedItemService = adWordsServices.get(session, FeedItemServiceInterface.class);
List<FeedItemOperation> feedItemOperations = new ArrayList<>();
DateTime now = DateTime.now();
DateTime marsDate = new DateTime(now.getYear(), now.getMonthOfYear(), 1, 0, 0);
feedItemOperations.add(createFeedItemAddOperation("Mars", "$1234.56", marsDate.toString("yyyyMMdd HHmmss"), adCustomizerFeed));
DateTime venusDate = new DateTime(now.getYear(), now.getMonthOfYear(), 15, 0, 0);
feedItemOperations.add(createFeedItemAddOperation("Venus", "$1450.00", venusDate.toString("yyyyMMdd HHmmss"), adCustomizerFeed));
FeedItemReturnValue feedItemReturnValue = feedItemService.mutate(feedItemOperations.toArray(new FeedItemOperation[feedItemOperations.size()]));
for (FeedItem addedFeedItem : feedItemReturnValue.getValue()) {
System.out.printf("Added feed item with ID %d.%n", addedFeedItem.getFeedItemId());
}
// Add feed item targeting to restrict the feed item to specific ad groups.
restrictFeedItemToAdGroup(adWordsServices, session, feedItemReturnValue.getValue(0), adGroupIds.get(0));
restrictFeedItemToAdGroup(adWordsServices, session, feedItemReturnValue.getValue(1), adGroupIds.get(1));
}
use of com.google.api.ads.adwords.axis.v201809.cm.FeedItemReturnValue in project googleads-java-lib by googleads.
the class AddDynamicPageFeed method createFeedItems.
/**
* Creates the page URLs in the DSA page feed.
*/
private static void createFeedItems(AdWordsServicesInterface adWordsServices, AdWordsSession session, DSAFeedDetails feedDetails, String labelName) throws RemoteException {
// Get the FeedItemService.
FeedItemServiceInterface feedItemService = adWordsServices.get(session, FeedItemServiceInterface.class);
// Create operations to add FeedItems.
FeedItemOperation[] operations = new FeedItemOperation[] { createDsaUrlAddOperation(feedDetails, "http://www.example.com/discounts/rental-cars", labelName), createDsaUrlAddOperation(feedDetails, "http://www.example.com/discounts/hotel-deals", labelName), createDsaUrlAddOperation(feedDetails, "http://www.example.com/discounts/flight-deals", labelName) };
FeedItemReturnValue result = feedItemService.mutate(operations);
for (FeedItem item : result.getValue()) {
System.out.printf("Feed item with feed item ID %d was added.%n", item.getFeedItemId());
}
}
Aggregations