Deleting YouTube videos using Zend/PHP
I'm using Zend and PHP to upload and delete videos from my home page. The uploading part is working fine but to dow开发者_运维知识库nload is more complicated.
$videoEntryToDelete = $yt->getVideoEntry($videoId);
$yt->delete($videoEntryToDelete);
I use this code to delete a video and the first row do work. The video object is created and I can get all data from it. But when I try to delete it I get this error message: "You must specify an URI to which to post"
Do anyone know how to solve this problem?
Thanks!
By default, getVideoEntry() gets a read only video object. In order to edit it, you must pass true in the third parameter for getVideoEntry(). The video object will then contain all of the metadata, including the URL required to delete it.
Try this:
$videoEntryToDelete = $yt->getVideoEntry($videoId, null, true);
$yt->delete($videoEntryToDelete);
there is also a method ready to use:
$videoEntryToDelete = $yt->getFullVideoEntry($videoId);
$yt->delete($videoEntryToDelete);
精彩评论