【问题标题】:Youtube API returns no resultsYoutube API 不返回任何结果
【发布时间】:2018-11-03 19:44:06
【问题描述】:

我在从 Youtube 加载视频播放列表时遇到问题。我关注this guide,但无法弄清楚出了什么问题,因为我没有收到错误消息。

 var YouTubeService = new YouTubeService(new BaseClientService.Initializer() { ApiKey = "MyAPIID"}); 
 var ChannelListRequest = YouTubeService.Channels.List("contentDetails");
 ChannelListRequest.ForUsername = "YoutubeUser";    
 var ListResponse = ChannelListRequest.Execute();

 foreach (var channel in ListResponse.Items) //No content in ListResponse.Items

当我执行请求时,它返回一个空响应。 API ID 是正确的,因为如果我使用旧的,它就会出错。我已尝试使用频道中的用户名和 ID,但没有任何效果。我错过了什么?

【问题讨论】:

  • 会不会是您的列表是私密的?
  • @NielsdeSchrijver 尝试了几个播放列表/频道均无效

标签: c# youtube-api google-api-dotnet-client


【解决方案1】:

好吧,我尝试了一些方法,并设法检索了我频道的播放列表,如下所示:

var service = new YouTubeService(new BaseClientService.Initializer()
{
     ApiKey = "yourapikey",
     ApplicationName = this.GetType().Name
});

var playListRequest = service.Playlists.List("snippet");
playListRequest.ChannelId = "yourchannelid";
var result = await playListRequest.ExecuteAsync();

使用您从该响应中获得的播放列表 ID,您可以像这样检索视频:

var playListItemsRequest = service.PlaylistItems.List("snippet");
playListItemsRequest.PlaylistId = "yourplaylistid";
var result = await playListItemsRequest.ExecuteAsync();

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-10-31
    • 2019-05-12
    • 2015-04-21
    • 2019-05-13
    • 1970-01-01
    • 2014-09-10
    • 2013-04-23
    相关资源
    最近更新 更多