I'm desperately trying to create a private playlist on youtube. It's no problem to create public playlists, the docs are very good. However I'm unable to "translate" the instructions to code.
You can use the API to update a playlist's title, description and or public/private status. To update a playlist, modify the PlaylistListEntry object for that playlist and then call the object's save method.
My code:
$httpClient = isset($_SESSION['sessionToken'])? Zend_Gdata_AuthSub::getHttpClient($_SESSION['sessionToken']) : null;
$this->youtube = new Zend_Gdata_YouTube($httpClient, "CompanyName-AppName-0.1", null, $this->apikey);
// ...
$yt = $this->youtube;
$newPlaylist = $yt->newPlaylistListEntry();
$newPlaylist->description = $yt->newDescription()->setText('My Description');
$newPlaylist->title = $yt->newTitle()->setText('My Title');
$postLocation = 'http://gdata.youtube.com/feeds/api/users/default/playlists';
try {
$yt->insertEntry($newPlaylist, $postLocation);
} catch (Zend_Gdata_App_Exception $e) {
echo $e->getMessage();
}
The last part is more or less the sample code from the docs. It works great, but the playlist is public.
From what I understand, $newPlaylist
is an instance of PlaylistListEntry
and thus there should be a method to make it private. I've inspected the object source code (and its over 9000 parent objects) plus the output of get_class_methods
, however I found no method which makes it private. Also just trying to set the private/public member to true/false doesn't help and leads to an error message (saying there's no such member).
I'm not very experienced with the YouTube API and Zend, I'd really appreciate if someone could help me out here.
From what I've read making a playlist private can be done by adding a <yt:private />
tag to the request. This sounds pretty simple, is there maybe a way to manually add it to the request?