Deleting YouTube videos using Zend/PHP

2019-02-14 15:49发布

问题:

I'm using Zend and PHP to upload and delete videos from my home page. The uploading part is working fine but to download 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!

回答1:

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


回答2:

there is also a method ready to use:

$videoEntryToDelete = $yt->getFullVideoEntry($videoId);
$yt->delete($videoEntryToDelete);