コード例 #1
0
 public virtual VideoSearchPage search(VideoSearchSelector selector) {
   object[] results = this.Invoke("search", new object[] { selector });
   return ((VideoSearchPage) (results[0]));
 }
コード例 #2
0
        /// <summary>
        /// Runs the code example.
        /// </summary>
        /// <param name="user">The AdWords user.</param>
        /// <param name="queryString">The video search query text.</param>
        public void Run(AdWordsUser user, string queryString)
        {
            // Get the VideoService.
              VideoService videoService = (VideoService) user.GetService(
              AdWordsService.v201309.VideoService);

              // Create a selector.
              VideoSearchSelector selector = new VideoSearchSelector();
              selector.searchType = VideoSearchSelectorSearchType.VIDEO;
              selector.query = queryString;
              selector.paging = new Paging();
              selector.paging.startIndex = 0;
              selector.paging.numberResults = PAGE_SIZE;

              try {
            // Run the query.
            VideoSearchPage page = videoService.search(selector);

            // Display videos.
            if (page != null && page.totalNumEntries > 0) {
              foreach (YouTubeVideo video in page.entries) {
            Console.WriteLine("YouTube video ID {0} with title {1} found.", video.id, video.title);
              }
              Console.WriteLine("Total number of matching videos: {0}.", page.totalNumEntries);
            } else {
              Console.WriteLine("No videos matching {0} were found.", queryString);
            }
              } catch (Exception ex) {
            throw new System.ApplicationException("Failed to search for videos.", ex);
              }
        }