/// <summary> /// Runs this sample. /// </summary> /// <param name="adsense">AdSense service object on which to run the requests.</param> /// <param name="adClientId">The ID for the ad client to be used.</param> /// <param name="maxPageSize">The maximum page size to retrieve.</param> public static void Run(AdsenseService adsense, string adClientId, int maxPageSize) { CommandLine.WriteLine("================================================================="); CommandLine.WriteLine("Listing all URL channels for ad client {0}", adClientId); CommandLine.WriteLine("================================================================="); // Retrieve URL channel list in pages and display data as we receive it. string pageToken = null; UrlChannels urlChannelResponse = null; do { var urlChannelRequest = adsense.Urlchannels.List(adClientId); urlChannelRequest.MaxResults = maxPageSize; urlChannelRequest.PageToken = pageToken; urlChannelResponse = urlChannelRequest.Fetch(); if (urlChannelResponse.Items != null && urlChannelResponse.Items.Count > 0) { foreach (var urlChannel in urlChannelResponse.Items) { CommandLine.WriteLine("URL channel with pattern \"{0}\" was found.", urlChannel.UrlPattern); } } else { CommandLine.WriteLine("No URL channels found."); } pageToken = urlChannelResponse.NextPageToken; } while (pageToken != null); CommandLine.WriteLine(); }
/// <summary>Displays all URL channels in an ad client.</summary> /// <param name="adClientId">The ID for the ad client to be used.</param> private void DisplayAllUrlChannels(string adClientId) { Console.WriteLine("================================================================="); Console.WriteLine("Listing all URL channels for ad client {0}", adClientId); Console.WriteLine("================================================================="); // Retrieve URL channel list in pages and display data as we receive it. string pageToken = null; UrlChannels urlChannelResponse = null; do { var urlChannelRequest = service.Accounts.Urlchannels.List(adSenseAccount.Id, adClientId); urlChannelRequest.MaxResults = maxListPageSize; urlChannelRequest.PageToken = pageToken; urlChannelResponse = urlChannelRequest.Execute(); if (!urlChannelResponse.Items.IsNullOrEmpty()) { foreach (var urlChannel in urlChannelResponse.Items) { Console.WriteLine("URL channel with pattern \"{0}\" was found.", urlChannel.UrlPattern); } } else { Console.WriteLine("No URL channels found."); } pageToken = urlChannelResponse.NextPageToken; }while (pageToken != null); Console.WriteLine(); }
/// <summary> /// This example gets all URL channels in an host ad client. /// </summary> /// <param name="adClientId">The ID for the ad client to be used.</param> private void GetAllUrlChannels(string adClientId) { Console.WriteLine("================================================================="); Console.WriteLine("Listing all URL channels for host ad client {0}", adClientId); Console.WriteLine("================================================================="); // Retrieve URL channel list in pages and display data as we receive it. string pageToken = null; UrlChannels urlChannelResponse = null; do { var urlChannelRequest = this.service.Urlchannels.List(adClientId); urlChannelRequest.MaxResults = this.maxListPageSize; urlChannelRequest.PageToken = pageToken; urlChannelResponse = urlChannelRequest.Execute(); if (urlChannelResponse.Items != null && urlChannelResponse.Items.Count > 0) { foreach (var urlChannel in urlChannelResponse.Items) { Console.WriteLine("URL channel with pattern \"{0}\" was found.", urlChannel.UrlPattern); } } else { Console.WriteLine("No URL channels found."); } pageToken = urlChannelResponse.NextPageToken; } while (pageToken != null); Console.WriteLine(); }