gpt4 book ai didi

php - Youtube API : Displaying thumbnails of each video. ..?

转载 作者:行者123 更新时间:2023-12-03 05:21:34 25 4
gpt4 key购买 nike

嗨,有人可以帮助我以正确的方式获得 默认.jpg 来自我正在拉入的 channel 的每个视频的图像?

<?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; ?>

最佳答案

这是一个示例,说明如何使用 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() 方法为您提供了该视频的缩略图数组及其内部网址。希望这可以帮助。

关于php - Youtube API : Displaying thumbnails of each video. ..?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9301806/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com