本文介绍了YouTube API - 没有针对用户名查询返回频道品牌设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

When using the YouTube API v3 to query a channel's branding settings, why are they returned for queries by channel ID, but not for queries by username? The API doesn't return branding settings for channel list queries by username.

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

If you query for a channel's branding settings by channel ID (e.g., id=UC8-Th83bH_thdKZDJCrn88g), you are returned a complete set of branding settings:

Google API 资源管理器:https://developers.google.com/youtube/v3/docs/channels/list

Google API Explorer: 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),您将完全没有品牌设置.不会返回或填充品牌设置.


If, on the other hand, you send a channel list query for a username (e.g., forUsername=latenight), you get no branding settings at all. The branding settings aren't returned or populated.

请求

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"
    }]
}

推荐答案

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

I may be wrong, but I believe that, in v3 of the APIs, Channel IDs are the only way to get a full response, as the concept of a "username" doesn't really exist in the same way anymore. That is, newly created YouTube channels are linked to a G+ profile and can have a display name, but there isn't really any YouTube username anymore associated with such a channel.

因为用户名曾经存在,而且他们仍然知道许多频道,所以forUsername"参数可以为您提供关联的频道 ID,然后使用该 ID 发出品牌设置请求.

Because usernames used to exist, though, and many channels are still known by them, the "forUsername" parameter is there to provide you the associated channelID and then issue the request for the branding settings with that.

现在,话虽如此,很明显 API 资源管理器页面上的语言并未反映这一点,也许问题就在于此;我从这个文档中得出我的结论:

Now, having said that, it's clear that the language on the API explorer page doesn't reflect that, and perhaps therein lies the problem; I'm taking my inferences from this documentation:

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

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

But it's always possible, too, that I'm reading incorrectly and you're actually seeing a new bug. The only way to know for sure would be to file it (or perhaps someone on the team could comment here)?

这篇关于YouTube API - 没有针对用户名查询返回频道品牌设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-23 22:47