【问题标题】:Retrieve the URL and the thumbnail from Youtube API (zend framework)从 Youtube API(zend 框架)检索 URL 和缩略图
【发布时间】:2012-06-27 04:39:14
【问题描述】:

我尝试使用 zend 显示视频播放列表,但在获取播放列表信息后,我不知道如何查找缩略图或缩略图的 url。

这是我的代码:

require_once 'Zend/Loader.php'; // the Zend dir must be in your include_path
Zend_Loader::loadClass('Zend_Gdata_YouTube');

 $yt = new Zend_Gdata_YouTube();
 $playlistListFeed = $yt->getPlaylistListFeed('admaltais');

 //step 1: show the playlist name and his URL
 foreach ($playlistListFeed as $playlistEntry) 
 {
    echo $playlistEntry->title->text . "</br></br>";
    echo $playlistEntry->getPlaylistVideoFeedUrl() . "</br></br>";
 }


 //step 2: parse the playlist
 $feedUrl = $playlistEntry->getPlaylistVideoFeedUrl();
 $playlistVideoFeed = $yt->getPlaylistVideoFeed('http://gdata.youtube.com/feeds/api/playlists/B15D7FD35D3814A5');

 foreach ($playlistVideoFeed as $playlistVideoFeedEntry) 
 {
   echo $playlistVideoFeedEntry->title->text . "</br></br>";
   //here i want to retrieve the infos
   //var_dump($playlistVideoFeedEntry);
 }

【问题讨论】:

    标签: zend-framework youtube thumbnails gdata playlist


    【解决方案1】:

    至于检索缩略图 URL,请查看 http://markmail.org/message/heekjb62yxf4skut 处的 getMediaArray() 函数。

    根据您的代码,您可以执行以下操作:

    $media = getMediaArray($playlistEntry);
    $thumbnail = isset($media['thumbnail']) ? $media['thumbnail'] : false;
    

    这对我有用,我不确定是否有更好的方法,但这是我目前能找到的最好方法。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-09-15
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多