YouTube API:如何启用获利功能

时间:2014-05-28 19:46:44

标签: php video youtube youtube-api

我有php youtube上传脚本。没问题,但所有上传的视频都关闭了货币化。我上传视频时是否可以通过API启用获利功能?这是我上传代码的一部分:

$yt = new Zend_Gdata_YouTube($httpClient, $applicationId, $clientId, $developerKey);

$myVideoEntry = new Zend_Gdata_YouTube_VideoEntry();
$filesource = $yt->newMediaFileSource('video.mp4');
$filesource->setContentType('video/quicktime');
$filesource->setSlug('video.mp4');
$myVideoEntry->setMediaSource($filesource);
$myVideoEntry->setVideoTitle('My Test Movie');
$myVideoEntry->setVideoDescription('My Test Movie');
// The category must be a valid YouTube category!
$myVideoEntry->setVideoCategory('Autos');
// Set keywords. Please note that this must be a comma-separated string
// and that individual keywords cannot contain whitespace
$myVideoEntry->SetVideoTags('personal');
// set some developer tags -- this is optional
// (see Searching by Developer Tags for more details)
$myVideoEntry->setVideoDeveloperTags(array('mydevtag', 'anotherdevtag'));


  // upload URI for the currently authenticated user
  $uploadUrl = 'http://uploads.gdata.youtube.com/feeds/api/users/default/uploads';
  // try to upload the video, catching a Zend_Gdata_App_HttpException,
  // if available, or just a regular Zend_Gdata_App_Exception otherwise
  try {
  $newEntry = $yt->insertEntry($myVideoEntry, $uploadUrl, 'Zend_Gdata_YouTube_VideoEntry');
  } catch (Zend_Gdata_App_HttpException $httpException) {
   echo $httpException->getRawResponseBody();
  } catch (Zend_Gdata_App_Exception $e) {
  echo $e->getMessage();

此功能正常,但上传视频已关闭获利功能。我尝试了一些像

 $myVideoEntry->setVideoEarning('1');

但它不起作用。

当我上传后手动启用货币化时,它就是功能,但我需要自动制作。

有什么想法吗?

1 个答案:

答案 0 :(得分:2)

我相信您可以使用Google内容所有者API启用获利功能("提出声明"),该内容所有者帐户可以使用该API。

https://developers.google.com/youtube/partner/