/// <summary> /// Runs the code example. /// </summary> /// <param name="user">The AdWords user.</param> /// <param name="campaignId">The campaign ID.</param> public void Run(AdWordsUser user, long campaignId) { // Get the VideoTargetingGroupCriterionService. VideoTargetingGroupCriterionService videoTargetingGroupCriterionService = (VideoTargetingGroupCriterionService) user.GetService( AdWordsService.v201402.VideoTargetingGroupCriterionService); int offset = 0; TargetingGroupCriterionPage page = new TargetingGroupCriterionPage(); try { // Create selector. TargetingGroupCriterionSelector selector = new TargetingGroupCriterionSelector(); selector.criteriaDimension = CriteriaDimension.KEYWORD; selector.campaignIds = new long[] { campaignId }; selector.paging = new Paging(); do { selector.paging.startIndex = offset; selector.paging.numberResults = PAGE_SIZE; // Get all keywords. page = videoTargetingGroupCriterionService.get(selector); // Display keywords. if (page != null && page.entries != null) { int i = offset; foreach (TargetingGroupCriterion targetingGroupCriterion in page.entries) { String negative = (targetingGroupCriterion is NegativeTargetingGroupCriterion) ? " (negative)" : ""; BaseKeyword keyword = (BaseKeyword) targetingGroupCriterion.criterion; Console.WriteLine("{0}) Criterion {1} ID {2}, targeting group ID {3} and " + "text '{4}'\n", i, negative, keyword.id, targetingGroupCriterion.targetingGroupId, keyword.text); i++; } } offset += PAGE_SIZE; } while (offset < page.totalNumEntries); Console.WriteLine("Number of keywords found: {0}", page.totalNumEntries); } catch (Exception ex) { throw new System.ApplicationException("Failed to get keywords.", ex); } }
public virtual TargetingGroupCriterionPage get(TargetingGroupCriterionSelector selector) { object[] results = this.Invoke("get", new object[] { selector }); return ((TargetingGroupCriterionPage) (results[0])); }