Php Youtube API:显示每个视频的缩略图。。。?

Php Youtube API:显示每个视频的缩略图。。。?,php,youtube,youtube-api,Php,Youtube,Youtube Api,您好,有人能帮我找到正确的方法,为我正在播放的频道中的每个视频获取default.jpg图像吗 <?php $url = 'http://gdata.youtube.com/feeds/api/users/utahblaze/uploads?orderby=updated&max-results=8'; $xml = simplexml_load_file($url); foreach ($xml->entry as $entry) : $kids = $entry

您好,有人能帮我找到正确的方法,为我正在播放的频道中的每个视频获取default.jpg图像吗

<?php
$url = 'http://gdata.youtube.com/feeds/api/users/utahblaze/uploads?orderby=updated&max-results=8';
$xml = simplexml_load_file($url);
foreach ($xml->entry as $entry) :

    $kids = $entry->children('http://search.yahoo.com/mrss/');
    $attributes = $kids->group->content[0]->attributes();
    $flv = $attributes['url'];
    $attributes = $kids->group->player->attributes();
    $link = $attributes['url']; 
?>

<a href="<?=$link?>">test</a?
<?php endforeach; ?>
条目作为$entry):
$kids=$entry->children('http://search.yahoo.com/mrss/');
$attributes=$kids->group->content[0]->attributes();
$flv=$attributes['url'];
$attributes=$kids->group->player->attributes();
$link=$attributes['url'];
?>

您是否尝试过GData类而不是直接处理Youtube API?我建议您使用捆绑在zend framework包中的官方类,因为从视频提要中提取特定数据会更容易

下面是一个示例,说明如何使用Zend Framework的GData Youtube类获取视频的图像url

<?php 
$yt = new Zend_Gdata_YouTube();
$query = $yt->newVideoQuery();
$query->videoQuery = 'cat';
$query->startIndex = 10;
$query->maxResults = 20;
$query->orderBy = 'viewCount';

$videoFeed = $yt->getVideoFeed($query);

foreach ($videoFeed as $videoEntry) : ?>
    <div class="video"> 
        <span>Title: <?php echo $videoEntry->getVideoTitle();?><span><br />
        <span>Description:<?php echo $videoEntry->getVideoDescription();?> </span> <br/>
        <?php $videoThumbnails = $videoEntry->getVideoThumbnails(); ?>
        <img alt="video-thumbnail" src="<?php echo $videoThumbnails[0]['url'];?>" />
    </div>
<?php endforeach; ?>

标题:
说明:
" />

如您所见,getVideoThumbnails()方法为您提供了该视频及其url的缩略图数组。希望这能有所帮助。

这是一个很好的PHP类,用于嵌入Youtube视频和播放列表。它为您提供了缩略图以及与视频相关的所有其他信息/元素


什么是default.jpg,480x360缩略图?@salathe不,我想它比这个小,可能是100x80之类的。你能帮我举个例子吗,我不知道它是如何获得ID或图像缩略图的