PHP - 如何通过 Youtube API v3 更改 youtube 视频的隐私状态? [英] PHP - How to change privacy status of a youtube video through Youtube API v3?

查看:25
本文介绍了PHP - 如何通过 Youtube API v3 更改 youtube 视频的隐私状态?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要知道如何更改 YouTube 视频的隐私状态.该视频的隐私状态为不公开",我想更改为公开".

I need to know how can I change the privacy status of a youtube video. The video have 'unlisted' privacy status and I want to change to 'public'.

这里有一个例子向视频添加一些标签,但我不知道如何应用更新隐私状态的示例.谢谢!

Here there is an example to add some tags to video but i don't know how to apply the example for update privacy status. Thank you!

推荐答案

我在上传视频到 YouTube 时设置了隐私状态.我相信更新视频也类似.

I have set the privacy status when uploading video to YouTube. I believe it similar for updating the video also.

我没有测试以下代码.但我希望你能试一试.

I didn't test the following code. But I hope you can give a shot.

首先检索视频状态属性.

First you retrieve the video status property.

$listResponse = $youtube->videos->listVideos('status', array('id' => $videoId));

然后获得视频状态属性

$video = $listResponse[0];
$videoStatus = $video['status'];

然后您设置视频状态.有效值为private"、public"、unlisted".

Then you set the video status. Valid values are 'private', 'public', 'unlisted'.

$videoStatus->privacyStatus = 'public';

最后你更新状态 &然后视频

Finally you update the status & then video

$video->setStatus($videoStatus);
$updateResponse = $youtube->videos->update('status', $video);

希望对你有帮助

这篇关于PHP - 如何通过 Youtube API v3 更改 youtube 视频的隐私状态?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆