PHP - How to change privacy status of a youtube vi

2019-03-06 04:09发布

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!

1条回答
来,给爷笑一个
2楼-- · 2019-03-06 04:41

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));

Then you get the video status property

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

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);

Hope this will help you

查看更多
登录 后发表回答