I am using Youtube API to upload some video, but I can\'t figure out how to add uploaded video to specific playlist. I have searched all over Google and I haven\'t found any
The code in the doc you linked to gives you a starting point:
$postUrl = $playlistToAddTo->getPlaylistVideoFeedUrl();
// video entry to be added
$videoEntryToAdd = $yt->getVideoEntry('4XpnKHJAok8');
// create a new Zend_Gdata_PlaylistListEntry, passing in the underling DOMElement of the VideoEntry
$newPlaylistListEntry = $yt->newPlaylistListEntry($videoEntryToAdd->getDOM());
// post
try {
$yt->insertEntry($newPlaylistListEntry, $postUrl);
} catch (Zend_App_Exception $e) {
echo $e->getMessage();
}
Instead of 4XpnKHJAok8
in that example, you'd want to pass in the id of the new video, i.e. the $idv
value in your script.
That code assumes that you have a $playlistToAddTo object already, but you probably will have a playlist ID instead. You can modify it to read
$postUrl = sprintf('https://gdata.youtube.com/feeds/api/playlists/%s?v=2', $playlistId);
where $playlistId
is the ID of the playlist you want to add the video to.