user3022751
user3022751

Reputation: 11

YouTube API: How to enable monetization

I have php youtube upload script. It s fine, but all uploaded videos are switched off monetization. Is it possible to enable monetization by API when I upload video? This is part of my upload code:

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

This is function ok, but uploadet video is switched off monetization. I try some like

 $myVideoEntry->setVideoEarning('1');

But it´s not function.

When I switched on monetization manualy after upload, it is function, but I need make it automaticaly.

Any ideas?

Upvotes: 0

Views: 1881

Answers (1)

troytc
troytc

Reputation: 662

I believe you can enable monetization ("make a claim") using the Google Content Owner API, which is available to those with a Content Owner account.

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

Upvotes: 2

Related Questions