查找youtube频道的频道id,以便您想订阅该频道或用于任何其他目的。
假设您想让用户通过点击订阅来订阅客户端应用程序的youtube频道。用户必须登录Google+,然后运行api请求才能订阅。因此,对于这个场景,您需要通道id。请注意,新的操作方式是Google+而不是GData
进入以下链接,将该频道的用户名[foofighters svevo]替换为该频道的用户名]
https://developers.google.com/apis-explorer/#p/youtube/v3/youtube.search.list?part=id&maxResults=1&q=foofightersVEVO&type=channel&_h=3&
执行查询并查看API响应:
GET https://www.googleapis.com/youtube/v3/search?part=id&maxResults=1&q=foofightersVEVO&type=channel&key={YOUR_API_KEY}
X-JavaScript-User-Agent: Google APIs Explorer
{
"kind": "youtube#searchListResponse",
"etag": ""2vd4g3cVsHAtTjJSdUMaBo1PBVE/6Ux-QcH6OQdn3t89j3y5z9RQhv0"",
"pageInfo": {
"totalResults": 161878,
"resultsPerPage": 1
},
"nextPageToken": "CAEQAA",
"items": [
{
"kind": "youtube#searchResult",
"etag": ""2vd4g3cVsHAtTjJSdUMaBo1PBVE/Q9-widOQXafayJk0l2DV9nrMYO0"",
"id": {
"kind": "youtube#channel",
"channelId": "UCGRjJrpD2bmk9Ilq6nq80qg"
}
}
]
}
注意这里的channelId。