Saturday, 15 January 2011

Delete video from Youtube with Zend Youtube API

A few weeks ago I was faced with problem of removing video from Youtube. Zend Youtube API was used for this purposes.

As the documentation describes, to delete a video it is necessary to get the video uploading channel for authenticated user and than invoke the delete method on the Zend_Gdata_YouTube service object, passing in the VideoEntry object that is being deleted.

The documentation and different web-dev blogs describes the process of the deleting video from Youtube using following code:
$videoEntryToDelete = $yt->getVideoEntry($videoId);
$yt->delete($videoEntryToDelete);
Looks simple, but the code example doesn't work. Method getVideoEntry doesn't provide the access to full control of the video.

To delete the video I used the method getFullVideoEntry() to get the videoEntry. The code example show how it can be done:
$videoEntry = $yt->getFullVideoEntry($videoId); 
$yt->delete($videoEntry) 

3 comments: