2

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?

svens
  • 11,438
  • 6
  • 36
  • 55

1 Answers1

0

I'm not sur about playlist, but one particural video could be marked like a "private" in the moment of upload by:

$myVideoEntry = new Zend_Gdata_YouTube_VideoEntry();
$myVideoEntry->setMediaSource($filesource);
$myVideoEntry->setVideoTitle($video_title);
// ... etc ...
$myVideoEntry->setVideoPrivate();

I know that you are searching about playlist, but maybe it could help you... for example by analizing code of this method, etc.

svens
  • 11,438
  • 6
  • 36
  • 55
sk_perl
  • 9
  • 1
  • Sorry for the late reaction. Unfortunately this doesn't work with playlists.. Also, according to `get_class_methods(..)` there aren't any functions with a similar name. Thanks for your answer anyway! – svens Mar 01 '11 at 13:37