使用 YouTube 设置频道部分国家/地区 API

Set the channelSection country using the YouTube API

我有一个 YouTube 频道。在该频道中,我有一个名为 "Brazil".

的 channelSection

我想限制该部分,以便只有巴西人可以查看。

在文档中我看到了如何为频道设置国家/地区参数,但不是 channelSection。

根据文档:https://developers.google.com/youtube/v3/docs/channelSections/update

我唯一可以更新的项目是:

我们的 YouTube 代表写信给我们说“要为频道资源设置 snippet.country 属性,您实际上需要更新 brandingSettings.channel.country 属性。此设置不会以任何方式影响定位。"

所以我有点困惑。我是将频道的 brandingSettings.channel.country 设置设为 Brazil 还是 channelSection,如果是,如何设置?

更新

按照下面的回答,我收到以下错误:

"domain": "global", "reason": "backendError", "message": "Backend Error" 

我认为他们可能对您尝试做的事情感到困惑。更改 brandingSettings.channel 属性 应该只设置

the country with which the channel is associated. [source]

我认为正确的方法是将 "Brazil" 添加到 targeting.regions[] 列表中。

来自文档:

targeting.countries[]: A list of ISO 3166-1 alpha-2 country codes where the channel section is visible. [source]

由于您已经创建了 channelSection,您只需使用 channelSections.update() 来提供 channelSection 资源并指定巴西作为目标国家/地区。根据 ISO 3166-1 国家代码列表,巴西的代码为“BR”。请注意,如果您正在提交更新请求并且您的请求没有为已有值的 属性 指定值,则 属性 的现有值将 被删除.

之后,您可以使用 channelSections.list() 检查您的 channelSection 资源,看看它应该只对巴西用户可见(targeting.countries[] 应该有“ BR" 作为唯一的值)。或者您可以使用一些代理扩展来查看来自不同国家/地区的频道部分,看看它是否按预期工作。