2

YouTube 引入了自动生成的频道,例如http://www.youtube.com/channel/UCH-BBvNWh1CONPAjpeocGcw。通过 channelId,我可以使用 API 来检索其关联的播放列表:

GET https://www.googleapis.com/youtube/v3/playlists?part=contentDetails&channelId=UCH-BBvNWh1CONPAjpeocGcw&key={YOUR_API_KEY}

得到,部分:

"items": [
{
"kind": "youtube#playlist",
"etag": "\"GbgM9_0DKhSLzW6BxAmfOJZH9RI/q_Rxfox9sHfH_r9g_LimnQeVsyU\"",
"id": "ALNb4maWNoT6RXC29sfG8iREznyAb9tqqJ",
"contentDetails": {
    "itemCount": 95
}
},......

每个播放列表都有一个 id 和一个 itemCount。当我使用 playlistId 时,我没有得到任何东西:

GET https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&id=ALNb4maWNoT6RXC29sfG8iREznyAb9tqqJ&key={YOUR_API_KEY}

得到我

{
"kind": "youtube#playlistItemListResponse",
"etag": "\"GbgM9_0DKhSLzW6BxAmfOJZH9RI/3cxjRXf86G9z5Bg7rup3QfCgrxM\"",
"pageInfo": {
    "totalResults": 0,
    "resultsPerPage": 5
},
"items": [
]
}

我错过了一步吗?

4

1 回答 1

3

Solved my own problem. The playlistId should be the "playlistId" parameter, not "id".

GET https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&playlistId=ALNb4maWNoT6RXC29sfG8iREznyAb9tqqJ&key={YOUR_API_KEY}
于 2013-11-13T00:31:11.293 回答