YouTube API-不返回按用户名查询的频道品牌设置



当使用YouTube API v3查询频道的品牌设置时,为什么按频道ID查询会返回这些设置,而按用户名查询不会返回这些设置?API不会按用户名返回频道列表查询的品牌设置。

如果您按频道ID(例如id=UC8-Th83bH_thdKZDJCrn88g)查询频道的品牌设置,则会返回一整套品牌设置:

Google API浏览器:https://developers.google.com/youtube/v3/docs/channels/list

请求

GET https://www.googleapis.com/youtube/v3/channels?part=brandingSettings&id=UC8-Th83bH_thdKZDJCrn88g&key={YOUR_API_KEY}

响应

{
// ... snip ...
"items": [
{
"kind": "youtube#channel",
"etag": ""..."",
"id": "UC8-Th83bH_thdKZDJCrn88g",
"brandingSettings": {
"channel": {
"title": "The Tonight Show Starring Jimmy Fallon",
"description": "Watch The Tonight Show Starring Jimmy Fallon Weeknights 11:35/10:35cnnThe Tonight Show Starring Jimmy Fallon features hilarious highlights from the show including: comedy sketches, music parodies, celebrity interviews, ridiculous games, and, of course, Jimmy's Thank You Notes and hashtags! You'll also find behind the scenes videos and other great web exclusives.",
// all the branding settings are here
}
}
}]
}

另一方面,如果您发送了一个用户名(例如forUsername=latenight)的频道列表查询,则会得到完全没有品牌设置的。不会返回或填充品牌设置。

请求

GET https://www.googleapis.com/youtube/v3/channels?part=brandingSettings&forUsername=latenight&key={YOUR_API_KEY}

响应

{
// ... snip ...
"items": [
{
"kind": "youtube#channel",
"etag": ""..."",
"id": "UC8-Th83bH_thdKZDJCrn88g"
}]
}

我可能错了,但我相信,在v3的API中,通道ID是获得完整响应的唯一方法,因为"用户名"的概念已经不存在了。也就是说,新创建的YouTube频道链接到G+个人资料,并且可以有一个显示名称,但实际上已经没有任何YouTube用户名与这样的频道相关联了。

不过,由于用户名曾经存在,而且许多频道仍然为他们所知,因此"forUsername"参数会为您提供相关的频道ID,然后发出品牌设置请求。

话虽如此,但很明显API资源管理器页面上的语言并没有反映出这一点,也许这就是问题所在;我从这个文档中推断:

https://developers.google.com/youtube/v3/guides/working_with_channel_ids#v3

从这个错误报告:

https://code.google.com/p/gdata-issues/issues/detail?id=4821&q=forUsername&colspec=API%20ID%20Type%20Status%20Priority%20Stars%20摘要

但也有可能,我读错了,而你实际上看到了一个新的错误。唯一确定的方法是提交(或者团队中的某个人可以在这里发表评论)?

最新更新