コード例 #1
0
        private static void createSiteLinksFeed(
      AdWordsUser user, SiteLinksDataHolder siteLinksData)
        {
            // Get the FeedService.
              FeedService feedService = (FeedService) user.GetService(AdWordsService.v201306.FeedService);

              // Create attributes.
              FeedAttribute textAttribute = new FeedAttribute();
              textAttribute.type = FeedAttributeType.STRING;
              textAttribute.name = "Link Text";
              FeedAttribute urlAttribute = new FeedAttribute();
              urlAttribute.type = FeedAttributeType.URL;
              urlAttribute.name = "Link URL";

              // Create the feed.
              Feed siteLinksFeed = new Feed();
              siteLinksFeed.name = "Feed For Site Links";
              siteLinksFeed.attributes = new FeedAttribute[] {textAttribute, urlAttribute};
              siteLinksFeed.origin = FeedOrigin.USER;

              // Create operation.
              FeedOperation operation = new FeedOperation();
              operation.operand = siteLinksFeed;
              operation.@operator = Operator.ADD;

              // Add the feed.
              FeedReturnValue result = feedService.mutate(new FeedOperation[] {operation});

              Feed savedFeed = result.value[0];
              siteLinksData.SiteLinksFeedId = savedFeed.id;
              FeedAttribute[] savedAttributes = savedFeed.attributes;
              siteLinksData.LinkTextFeedAttributeId = savedAttributes[0].id;
              siteLinksData.LinkUrlFeedAttributeId = savedAttributes[1].id;
              Console.WriteLine("Feed with name {0} and ID {1} with linkTextAttributeId {2}"
              + " and linkUrlAttributeId {3} was created.", savedFeed.name, savedFeed.id,
              savedAttributes[0].id, savedAttributes[1].id);
        }
コード例 #2
0
        /// <summary>
        /// Create a feed for holding upgraded sitelinks.
        /// </summary>
        /// <param name="feedService">The feed service.</param>
        /// <returns>A SiteLinksFeed for holding the sitelinks.</returns>
        private static SiteLinksFeed createSiteLinksFeed(FeedService feedService)
        {
            SiteLinksFeed siteLinksData = new SiteLinksFeed();

              // Create attributes.
              FeedAttribute textAttribute = new FeedAttribute();
              textAttribute.type = FeedAttributeType.STRING;
              textAttribute.name = "Link Text";
              FeedAttribute urlAttribute = new FeedAttribute();
              urlAttribute.type = FeedAttributeType.URL;
              urlAttribute.name = "Link URL";

              // Create the feed.
              Feed siteLinksFeed = new Feed();
              siteLinksFeed.name = "Feed For Sitelinks";
              siteLinksFeed.attributes = new FeedAttribute[] {textAttribute, urlAttribute};
              siteLinksFeed.origin = FeedOrigin.USER;

              // Create operation.
              FeedOperation operation = new FeedOperation();
              operation.operand = siteLinksFeed;
              operation.@operator = Operator.ADD;

              // Add the feed.
              FeedReturnValue result = feedService.mutate(new FeedOperation[] {operation});

              Feed savedFeed = result.value[0];
              siteLinksData.SiteLinksFeedId = savedFeed.id;
              FeedAttribute[] savedAttributes = savedFeed.attributes;
              siteLinksData.LinkTextFeedAttributeId = savedAttributes[0].id;
              siteLinksData.LinkUrlFeedAttributeId = savedAttributes[1].id;
              return siteLinksData;
        }