YouTube v3 API上传到频道
我必须使用YouTube的v2 API将我的PHP脚本迁移到v3.
I have to migrate my PHP scripts using YouTube's v2 API to v3.
我正在尝试通过以下示例上传视频:
I'm trying this example to upload a video:
https://developers.google.com/youtube/v3/code_samples/php#resumable_uploads
我可以为我的应用验证我的Google帐户,唯一的问题是该视频正在上传到我的Google+ YouTube频道,而不是我的原始频道. (它们都属于同一个Google帐户).
I can authenticate my Google account for my app, the only problem is that the video is being uploaded to my Google+ YouTube channel and not to my original channel. (They both belong to the same Google account).
我无法使用v2 API解决此问题,但在频道切换器"中选择了默认"频道(
I was not able to solve this problem with the v2 API but selecting the "default" channel in "Channel switcher" (https://www.youtube.com/channel_switcher) did help.
如何告诉v3 API上传到哪个频道?
How can I tell the v3 API which channel to upload to?
The videos.insert
method supports an optional parameter onBehalfOfContentOwnerChannel
, which takes in a a YouTube channel ID value as a string. You must also provide your YouTube CMS auth credentials for the onBehalfOfContentOwner
parameter as well.
YouTube提供了一些说明:
YouTube provides some explanation:
此[onBehalfOfContentOwnerChannel]参数适用于拥有并拥有 管理许多不同的YouTube频道.它允许内容所有者 进行一次身份验证并代表渠道执行操作 在参数值中指定,而无需提供 每个单独通道的身份验证凭据.
This [onBehalfOfContentOwnerChannel] parameter is intended for YouTube content partners that own and manage many different YouTube channels. It allows content owners to authenticate once and perform actions on behalf of the channel specified in the parameter value, without having to provide authentication credentials for each separate channel.
videos.insert
此处的相关API文档.
Relevant API documentation for videos.insert
here.