PHP:通过YouTube API更改视频的隐私状态

时间:2013-12-04 16:58:37

标签: php youtube-api

我想知道如何在youtube api中更新视频的隐私状态。更新代码段就是这样的。

     $updateVideo = new Google_Video($video);
     $updateSnippet = new Google_VideoSnippet($videoSnippet);

     $updateSnippet->setTitle($title);
     $updateSnippet->setDescription($description);
     $updateSnippet->setTags($tags);

     $updateVideo -> setSnippet($updateSnippet);

     $updateResponse = $youtube->videos->update("snippet", $updateVideo);
     $responseTags = $updateResponse['snippet'];

正在考虑您是否正在更新标题,说明和标签。任何帮助表示赞赏。感谢

1 个答案:

答案 0 :(得分:1)

喜欢这个......

// Create a video status with privacy status. Options are "public", "private" and "unlisted".


 $updateVideo = new Google_Video($video);
 $updateSnippet = new Google_VideoSnippet($videoSnippet);

 $updateSnippet->setTitle($title);
 $updateSnippet->setDescription($description);
 $updateSnippet->setTags($tags);

$status = new Google_VideoStatus();//here
$status->privacyStatus = "private";//here
 $updateVideo -> setSnippet($updateSnippet);
$updateVideo->setStatus($status);//and here

//Updated this line to have "status,snippet"
 $updateResponse = $youtube->videos->update("status,snippet", $updateVideo);
 $responseTags = $updateResponse['snippet'];