如何使用视频ID获取dailymotion视频的缩略图

时间:2015-05-18 17:00:06

标签: php dailymotion-api video-thumbnails

我已经查看了很多信息,但暂时找不到工作版本。

我从这篇文章中获取了代码: How to get the video thumbnail from Dailymotion video from the video id of that video like in youtube?

$id='xwxadz'; // ID DAILYMOTION EXAMPLE
$thumbnail_medium_url='https://api.dailymotion.com/video/'.$id.'?fields=thumbnail_medium_url';
$json_thumbnail = file_get_contents($thumbnail_medium_url);
$get_thumbnail = json_decode($json_thumbnail, TRUE);
$thumb=$get_thumbnail['thumbnail_medium_url'];
echo $thumb; // Output Example : http://s2.dmcdn.net/BJL4o/160x120-mzR.jpg

输出:

Warning: file_get_contents() [function.file-get-contents]: Unable to find the wrapper "https" - did you forget to enable it when you configured PHP? in Z:\home\static.loc\www\new.php on line 4

Warning: file_get_contents(https://api.dailymotion.com/video/xwxadz?fields=thumbnail_medium_url) [function.file-get-contents]: failed to open stream: No error in Z:\home\static.loc\www\new.php on line 4

1 个答案:

答案 0 :(得分:0)

缩略图类型:

url thumbnail_60_url    size : 60px     
url thumbnail_120_url   size : 120px     
url thumbnail_180_url   size : 180px     
url thumbnail_240_url   size : 240px     
url thumbnail_360_url   size : 360px     
url thumbnail_480_url   size : 480px     
url thumbnail_720_url   size : 720px     
url thumbnail_url       size : 86px

我已准备好执行此代码

GET方法此网址:https://api.dailymotion.com/video/&#39; + videoID +&#39;?fields = id,thumbnail_url,thumbnail_60_url,thumbnail_120_url,thumbnail_240_url,humbnail_360_url,thumbnail_480_url,thumbnail_720_url < / p>