API端点/活动不返回历史活动(只有最近的活动可访问)

时间:2017-11-24 09:28:30

标签: youtube-api youtube-data-api google-apis-explorer

这是我可以向下滚动的最旧页面,用于TEDx会谈频道的activities.list API

GET https://www.googleapis.com/youtube/v3/activities?part=snippet&channelId=UCsT0YIqwnpJCM-mx7-gSA4Q&maxResults=50&pageToken=CPoBEAA&fields=items(snippet(publishedAt%2Ctitle))%2CnextPageToken%2CprevPageToken&key={YOUR_API_KEY}

并且回复是

{
    "prevPageToken": "CPoBEAE",
    "items": [
       {
           "snippet": {
             "publishedAt": "2017-11-21T18:30:36.000Z",
             "title": "You Are Not Who They Think You Are | Vinny McCoy | TEDxDrogheda"
           }
       },
       {
           "snippet": {
             "publishedAt": "2017-11-21T18:27:43.000Z",
             "title": "What does it mean to be authentic? | Sarah Archer | TEDxDrogheda"
           }
       },
       {
           "snippet": {
             "publishedAt": "2017-11-21T18:27:33.000Z",
             "title": "Moments in Jazz |  Jazz Quartet of the Conservatory of the Polyphonic Choir of Patras | TEDxPatras"
           }
       },
       {
           "snippet": {
             "publishedAt": "2017-11-20T20:14:23.000Z",
             "title": "Moments in Jazz |  Jazz Quartet of the Conservatory of the Polyphonic Choir of Patras | TEDxPatras"
           }
       },
       {
           "snippet": {
             "publishedAt": "2017-11-21T18:22:57.000Z",
             "title": "Adriano Teixeira | Adriano Teixeira | TEDxPassoFundo"
           }
       },
       {
           "snippet": {
             "publishedAt": "2017-11-21T18:21:50.000Z",
             "title": "Eargasm - Beat Box Act by Ivory Parker aka neXor | Ivory Parker | TEDxDonauinsel"
           }
       }
  ]    
}

您可以看到没有nextPageToken意味着您无法进一步滚动,而且最早的活动已经

"publishedAt":  "2017-11-21T18:21:50.000Z" 

同时,至少有这个视频

https://www.youtube.com/results?search_query=xzA-QZ0yqJg

2017-10-24发表。

UPD :报告的问题案例已在Youtube API端修复。

1 个答案:

答案 0 :(得分:0)

您正在询问返回activities列表的"kind": "youtube#activity",并且您提供的项目作为示例列为"kind": "youtube#video"。如果您使用video端点而不是activities,您也会找到该项目。

<强>更新

看起来调用所服务的historycal活动有限。 我通过指定publishedBefore参数成功浏览了这些活动。分页将为您带来更多。

例如

获取https://www.googleapis.com/youtube/v3/activities?part=snippet%2CcontentDetails&channelId=UCsT0YIqwnpJCM-mx7-gSA4Q&maxResults=50&pageToken=CGQQAA&publishedBefore=2017-10-25T18%3A21%3A50.000Z&fields=items(snippet(publishedAt%2Ctitle))%2CnextPageToken&key= {YOUR_API_KEY}

显然,将来使用的日期可以涵盖所有内容。