【问题标题】:Retrieve public statistics of video via youtube api通过 youtube api 检索视频的公共统计信息
【发布时间】:2013-09-03 01:09:20
【问题描述】:

可以获取视频的公开统计信息吗?

使用这样的东西,我可以获得视频的总观看次数和点赞数:

https://www.googleapis.com/youtube/v3/videos?part=statistics&key=API_KEY&id=ekzHIouo8Q4

有可能获得那些公开的统计数据吗? 我发现了这个问题

Youtube GData API : Retrieving public statistics

但也许有些事情发生了变化?

【问题讨论】:

    标签: statistics youtube-api information-retrieval


    【解决方案1】:

    在 API 版本 3 下唯一可以获取统计信息的 API 调用是 youtube.videos.list API

    试试这个 API Explorer 链接试试:

    https://developers.google.com/apis-explorer/#p/youtube/v3/youtube.videos.list?part=snippet%252C+statistics&id=Ys7-6_t7OEQ&maxResults=50&_h=2&

    【讨论】:

      【解决方案2】:

      你可以使用Analytics API获取那些

      Sample requests 会帮助你理解。

      Analytics API 是一项不同的服务,但库位于同一个包中,您可以通过添加“https://www.googleapis.com/auth/yt-analytics.readonly”范围来使用相同的授权

      【讨论】:

        【解决方案3】:

        您需要创建 YouTubeService 对象并获取关键字的搜索结果

        YouTubeService youtubeService = new YouTubeService(new BaseClientService.Initializer()
        {
          ApiKey = "dfhdufhdfahfujashfd",
          ApplicationName = this.GetType().ToString()
        });
        
         var searchListRequest = youtubeService.Search.List("snippet");
              searchListRequest.Q = "cute cats"; 
              searchListRequest.MaxResults = 10;
        
          var searchListResponse = await searchListRequest.ExecuteAsync();
          var videoId = searchListResponse.Items.First().Id.VideoId is the unique id of the video
        
        // Video Request    
        VideosResource.ListRequest request = new VideosResource.ListRequest(youTubeService, "statistics")
        {
          Id = videoId
        };
        
        VideoListResponse response = request.Execute();
        if (response.Items.First() != null && response.Items.First().Statistics != null)
        {
          Console.WriteLine(response.Items.First().Statistics.ViewCount);
        }
        

        【讨论】:

          猜你喜欢
          • 2014-05-27
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2017-01-20
          相关资源
          最近更新 更多