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->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; ?>
Hi can someone assist me with the proper way to get the default.jpg image for every video from the channels i'm pulling in?
<?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; ?>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这是一个示例,说明如何使用 Zend Framework 的 GData Youtube 类获取视频的图像 url。
正如您所看到的, getVideoThumbnails() 方法为您提供了该视频的缩略图数组及其内部的 url。希望这有帮助。
Here it's an example of how you could get the image url of a video using the GData Youtube class of Zend Framework.
As you can see the getVideoThumbnails() method gives you an array of thumbnails for that video and their url inside. Hope this helps.
您是否尝试过使用 GData 类而不是直接处理 Youtube API?我建议您使用 zend 框架包中捆绑的官方类,因为您可以更轻松地从视频源中提取特定数据。 http://framework.zend.com/manual/en/zend.gdata .youtube.html
Have you tried the GData class instead of dealing with the Youtube API directly? I'd recommend you to use the official class which is bundled in the zend framework package as it will be easier to you to pull specific data from the video feeds. http://framework.zend.com/manual/en/zend.gdata.youtube.html
这是一个很好的 PHP 类,用于嵌入 Youtube 视频和播放列表。它为您提供缩略图以及与视频相关的所有其他信息/元素。
PHP Youtube 课程
Here's a nice PHP class for embedding Youtube videos and playlists. It gives you thumbnails, and all other information / elements associated with the video.
PHP Youtube Class