【问题标题】:YouTube API - No channel branding settings returned for queries by usernameYouTube API - 未针对用户名查询返回频道品牌设置
【发布时间】:2014-04-07 02:35:56
【问题描述】:

使用 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:35c\n\nThe 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"
    }]
}

【问题讨论】:

    标签: youtube youtube-api


    【解决方案1】:

    我可能错了,但我相信,在 API 的 v3 中,频道 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%20Summary

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

    【讨论】:

    • 不,我想说你链接的指南很好地涵盖了它,谢谢。不知何故,我的搜索错过了它。 “...v3 旨在以相同方式对待有和没有旧用户名的频道,这意味着在任何地方都使用频道 ID。” 如果用户名存在并标识一个或多个频道,它并不能真正解释为什么它不应该返回相同的结果,但我现在明白这是做出的选择。
    猜你喜欢
    • 2019-02-03
    • 1970-01-01
    • 2019-09-01
    • 1970-01-01
    • 2017-04-22
    • 2020-07-13
    • 2013-01-29
    • 1970-01-01
    相关资源
    最近更新 更多