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

前端 未结 1 1761
半阙折子戏
半阙折子戏 2021-01-07 08:31

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 a

相关标签:
1条回答
  • 2021-01-07 08: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

    0 讨论(0)
提交回复
热议问题