API 端点 /activities 没有 return 历史活动(只能访问最近的活动)
API endpoint /activities doesn't return historical activities (only very recent ones are accessible)
这是我可以向下滚动的最旧页面 activities.list API TEDx Talks 频道
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 意味着你不能再滚动了,最旧的 activity 有
"publishedAt": "2017-11-21T18:21:50.000Z"
同时,至少有这个视频
https://www.youtube.com/results?search_query=xzA-QZ0yqJg
2017 年 10 月 24 日发布。
UPD:报告的问题案例已在 Youtube API 端修复。
您正在查询 activities
,它返回 "kind": "youtube#activity"
的列表,您作为示例提供的项目列为 "kind": "youtube#video"
。如果您使用 video
端点而不是 activities
,您也会找到该项目。
更新
呼叫提供的历史活动似乎有限制。
我通过指定 publishedBefore
参数成功浏览了活动。分页会让你走得更远。
例如
显然,使用的日期可以是将来涵盖所有内容的日期。
这是我可以向下滚动的最旧页面 activities.list API TEDx Talks 频道
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 意味着你不能再滚动了,最旧的 activity 有
"publishedAt": "2017-11-21T18:21:50.000Z"
同时,至少有这个视频
https://www.youtube.com/results?search_query=xzA-QZ0yqJg
2017 年 10 月 24 日发布。
UPD:报告的问题案例已在 Youtube API 端修复。
您正在查询 activities
,它返回 "kind": "youtube#activity"
的列表,您作为示例提供的项目列为 "kind": "youtube#video"
。如果您使用 video
端点而不是 activities
,您也会找到该项目。
更新
呼叫提供的历史活动似乎有限制。
我通过指定 publishedBefore
参数成功浏览了活动。分页会让你走得更远。
例如
显然,使用的日期可以是将来涵盖所有内容的日期。