ricopo
ricopo

Reputation: 475

PHP - How to change privacy status of a youtube video through Youtube API v3?

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!

Upvotes: 2

Views: 5489

Answers (1)

Saumini Navaratnam
Saumini Navaratnam

Reputation: 8850

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

Upvotes: 5

Related Questions