Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>if you are using the zend google api library, it's pretty easy to get a playlist feed, and catch any errors that google will return if it does not exist. The simplest solution is to get a list of all playlists on the account and loop through to see if the playlist id matches the id you have, and then go from there to get the playlist entries. That way there really isn't ever going to be any errors or exceptions. But, that is making multiple calls, which you were trying to avoid. In order to make a single call, you'd need to have the playlist feed url and then make one call and catch the exception. These are snippets of a couple of the functions I've used when working with YouTube playlists.</p> <p>Option 1:</p> <pre><code>$this-&gt;api = new Zend_Gdata_YouTube(); $this-&gt;api-&gt;setMajorProtocolVersion(2); $feed = $this-&gt;api-&gt;retrieveAllEntriesForFeed($this-&gt;api-&gt;getPlaylistListFeed('default')); $playlistEntry = $this-&gt;__getPlaylistEntryFromFeed($feed, $playlistID); //do what you want with the playlist entry, like get the list of all the videos function __getPlaylistEntryFromFeed($feed, $entryId) { foreach($feed as $entry) { if($entry-&gt;getPlaylistId()-&gt;text == $entryId) { return $entry; } } } </code></pre> <p>Option 2:</p> <pre><code>try { $playlistVideoFeed = $this-&gt;api-&gt;getPlaylistVideoFeed($playlistFeedUrl. '?v=2&amp;start-index=1'); //this returns a list of videos in the playlist that you can loop through. see example function below. } catch (Zend_Gdata_App_Exception $e) { echo $e-&gt;getMessage(); } function getPlaylistVideos($playlistFeedUrl, $start=1, $total=0, $videos = array()) { $playlistVideoFeed = $this-&gt;api-&gt;getPlaylistVideoFeed($playlistFeedUrl. '?v=2&amp;start-index='.$start); foreach ($playlistVideoFeed as $videoEntry) { $videos[] = $this-&gt;getDataFromVideoEntry($videoEntry); } $count = count($playlistVideoFeed); if(count($videos) &lt; $total &amp;&amp; $count != 0) { $videos = $this-&gt;getPlaylistvideos($playlistFeedUrl, $start + ($count-1), $total, $videos); } return $videos; } </code></pre> <p>To take those examples and use them with your code, you could try look something like this:</p> <pre><code># Playlist ID from URL $playlist=$_GET['playlist']; # Assign the Playlist Items to a variable. $video_search; try { $video_search = $yt-&gt;PlaylistItems($playlist); } catch(Google_ServiceException $e) { //there was an error echo $e-&gt;getMessage(); } </code></pre> <p>Hope that helps.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload