/// <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 VideoTargetingGroupService. VideoTargetingGroupService videoTargetingGroupService = (VideoTargetingGroupService) user.GetService(AdWordsService.v201406.VideoTargetingGroupService); int offset = 0; TargetingGroupPage page = new TargetingGroupPage(); try { // Create selector. TargetingGroupSelector selector = new TargetingGroupSelector(); selector.campaignIds = new long[] { campaignId }; selector.paging = new Paging(); do { selector.paging.startIndex = offset; selector.paging.numberResults = PAGE_SIZE; // Get all targeting groups for this account. page = videoTargetingGroupService.get(selector); // Display the results. if (page != null && page.entries != null) { int i = offset; foreach (TargetingGroup targetingGroup in page.entries) { Console.WriteLine("{0}) Targeting group ID {1}, campaign ID {2} and name '{3}'", (i + 1), targetingGroup.id, targetingGroup.campaignId, targetingGroup.name); i++; } } else { Console.WriteLine("No targeting groups were found."); } offset += PAGE_SIZE; } while (offset < page.totalNumEntries); Console.WriteLine("Number of targeting groups found: {0}", page.totalNumEntries); } catch (Exception ex) { throw new System.ApplicationException("Failed to get targeting groups.", ex); } }
public virtual TargetingGroupPage get(TargetingGroupSelector selector) { object[] results = this.Invoke("get", new object[] { selector }); return ((TargetingGroupPage) (results[0])); }