private static void createSitelinksFeedMapping(AdWordsUser user, SitelinksDataHolder sitelinksData) { using (FeedMappingService feedMappingService = (FeedMappingService)user.GetService(AdWordsService.v201806.FeedMappingService)) { // Map the FeedAttributeIds to the fieldId constants. AttributeFieldMapping linkTextFieldMapping = new AttributeFieldMapping() { feedAttributeId = sitelinksData.LinkTextFeedAttributeId, fieldId = PLACEHOLDER_FIELD_SITELINK_LINK_TEXT }; AttributeFieldMapping linkFinalUrlFieldMapping = new AttributeFieldMapping() { feedAttributeId = sitelinksData.LinkFinalUrlFeedAttributeId, fieldId = PLACEHOLDER_FIELD_SITELINK_FINAL_URL }; AttributeFieldMapping line2FieldMapping = new AttributeFieldMapping() { feedAttributeId = sitelinksData.Line2FeedAttributeId, fieldId = PLACEHOLDER_FIELD_LINE_2_TEXT }; AttributeFieldMapping line3FieldMapping = new AttributeFieldMapping() { feedAttributeId = sitelinksData.Line3FeedAttributeId, fieldId = PLACEHOLDER_FIELD_LINE_3_TEXT }; // Create the FieldMapping and operation. FeedMappingOperation operation = new FeedMappingOperation() { operand = new FeedMapping() { placeholderType = PLACEHOLDER_SITELINKS, feedId = sitelinksData.FeedId, attributeFieldMappings = new AttributeFieldMapping[] { linkTextFieldMapping, linkFinalUrlFieldMapping, line2FieldMapping, line3FieldMapping } }, @operator = Operator.ADD }; // Save the field mapping. FeedMappingReturnValue result = feedMappingService.mutate(new FeedMappingOperation[] { operation }); foreach (FeedMapping savedFeedMapping in result.value) { Console.WriteLine( "Feed mapping with ID {0} and placeholderType {1} was saved for feed with ID {2}.", savedFeedMapping.feedMappingId, savedFeedMapping.placeholderType, savedFeedMapping.feedId); } } }
private static void createSiteLinksFeedMapping( AdWordsUser user, SiteLinksDataHolder siteLinksData) { // Get the FeedItemService. FeedMappingService feedMappingService = (FeedMappingService)user.GetService(AdWordsService.v201406.FeedMappingService); // Map the FeedAttributeIds to the fieldId constants. AttributeFieldMapping linkTextFieldMapping = new AttributeFieldMapping(); linkTextFieldMapping.feedAttributeId = siteLinksData.LinkTextFeedAttributeId; linkTextFieldMapping.fieldId = PLACEHOLDER_FIELD_SITELINK_LINK_TEXT; AttributeFieldMapping linkUrlFieldMapping = new AttributeFieldMapping(); linkUrlFieldMapping.feedAttributeId = siteLinksData.LinkUrlFeedAttributeId; linkUrlFieldMapping.fieldId = PLACEHOLDER_FIELD_SITELINK_URL; // Create the FieldMapping and operation. FeedMapping feedMapping = new FeedMapping(); feedMapping.placeholderType = PLACEHOLDER_SITELINKS; feedMapping.feedId = siteLinksData.SiteLinksFeedId; feedMapping.attributeFieldMappings = new AttributeFieldMapping[] { linkTextFieldMapping, linkUrlFieldMapping }; FeedMappingOperation operation = new FeedMappingOperation(); operation.operand = feedMapping; operation.@operator = Operator.ADD; // Save the field mapping. FeedMappingReturnValue result = feedMappingService.mutate(new FeedMappingOperation[] { operation }); foreach (FeedMapping savedFeedMapping in result.value) { Console.WriteLine( "Feed mapping with ID {0} and placeholderType {1} was saved for feed with ID {2}.", savedFeedMapping.feedMappingId, savedFeedMapping.placeholderType, savedFeedMapping.feedId); } }