Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Youtube api playlist id

Tags:

php

youtube

I am using the test code found @ http://code.google.com/apis/youtube/2.0/developers_guide_php.html to create a playlist:

$newPlaylist = $yt->newPlaylistListEntry();
$newPlaylist->summary = $yt->newDescription()->setText($desc);
$newPlaylist->title = $yt->newTitle()->setText($title);
// post the new playlist
$postLocation = 'http://gdata.youtube.com/feeds/api/users/default/playlists';
try {
  $playlist = $yt->insertEntry($newPlaylist, $postLocation);
  } 
catch (Zend_Gdata_App_Exception $e) {
  echo $e->getMessage();
}

The playlist is created, but how can I get the id or url of the playlist that was just created?

like image 483
John Avatar asked Mar 21 '26 07:03

John


1 Answers

I have the same problem. I have managed to get a bit further but I still can't get the playlistID. Here is what I did:

instead of:

$playlist = $yt->insertEntry($newPlaylist, $postLocation);

I used :

$playlist = $yt->insertEntry($newPlaylist, $postLocation, 'Zend_Gdata_YouTube_PlaylistListEntry');

But when I try to get the id by $playlist->getPlaylistID() or $playlist->playlistId->text I get the same exception which says :

The yt:playlistId element is not supported in versions earlier than 2.

even if I have set it earlier with $yt->setMajorProtocolVersion(2);

like image 104
Calin Avatar answered Mar 22 '26 22:03

Calin