如何使用youtube api v3获取我订阅的所有频道

时间:2015-12-09 03:13:26

标签: youtube youtube-api youtube-javascript-api

我是youtube api v3的新手,在获取所有订阅频道时遇到问题。我订阅了65个频道,但每个api电话只能获得50个频道。那么,有没有办法搞定所有?

另一件事是,我有一个channelID,是否有任何api可以在我订阅的频道列表中查看此频道?

1 个答案:

答案 0 :(得分:0)

Youtube API限制每次调用50个结果。如果你问你是否可以在同一个电话中获得全部65,那么答案是否定的。但是,如果你的意思是是否可以检索所有65个,是的。您需要使用nextPageToken参数值并将其传递给pageToken参数,该参数将带您进入下一页。在代码中,可以通过以下方式处理它(如documentation所示):

var nextPageToken = '';

    // This loop retrieves a set of playlist items and checks the nextPageToken 
    // in the response to determine whether the list contains additional items. 
    // It repeats that process until it has retrieved all of the items in the list.

    while (nextPageToken != null) {
      var playlistResponse = YouTube.PlaylistItems.list('snippet', {
        playlistId: playlistId,
        maxResults: 25,
        pageToken: nextPageToken
      });

关于您的ChannelID问题,根据您的描述,我了解您要检查您是否订阅了特定频道,以防您拥有该ID。我相信Youtube API的Activities方法应该可以帮助您。查看contentDetails.subscription属性。我希望能解决你的问题。

相关问题