【发布时间】:2018-05-03 18:01:12
【问题描述】:
我有一个 vimeo api 密钥,我上传了这个 url https://vimeo.com 的视频,并从这个链接 https://vimeo.com/home/myvideos 获取我的所有视频链接。现在我收到了所有视频链接详细信息的回复。
<?php
$urls = array();
$videos = array();
// vimeo test
$urls[] = 'https://vimeo.com/243625359';
$urls[] = 'https://vimeo.com/243438242';
foreach ($urls as $url) {
$videos[] = getVideoDetails($url);
}
function getVideoDetails($url)
{
$host = explode('.', str_replace('www.', '', strtolower(parse_url($url, PHP_URL_HOST))));
$host = isset($host[0]) ? $host[0] : $host;
switch ($host) {
case 'vimeo':
$video_id = substr(parse_url($url, PHP_URL_PATH), 1);
$hash = json_decode(file_get_contents("http://vimeo.com/api/v2/video/{$video_id}.json"));
// header("Content-Type: text/plain");
// print_r($hash);
// exit;
return array(
'provider' => 'Vimeo',
'title' => $hash[0]->title,
'description' => str_replace(array("<br>", "<br/>", "<br />"), NULL, $hash[0]->description),
'description_nl2br' => str_replace(array("\n", "\r", "\r\n", "\n\r"), NULL, $hash[0]->description),
'thumbnail' => $hash[0]->thumbnail_large,
'video' => "https://vimeo.com/" . $hash[0]->id,
'embed_video' => "https://player.vimeo.com/video/" . $hash[0]->id,
);
break;
}
}
header("Content-Type: text/plain");
print_r($videos);
回复:
Array
(
[0] => Array
(
[provider] => Vimeo
[title] => SampleVideo_1280x720_10mb
[description] => Vimeo was born in 2004, created by a group of
filmmakers who wanted an easy and beautiful way to share videos with
their friends. Word started to spread, and an insanely supportive
community of creators began to blossom. Now Vimeo is home to more
than:
[description_nl2br] => Vimeo was born in 2004, created by a group of
filmmakers who wanted an easy and beautiful way to share videos
with their friends. Word started to spread, and an insanely
supportive community of creators began to blossom. Now Vimeo is home
to more than:
[thumbnail] => http://i.vimeocdn.com/video/667808655_640.jpg
[video] => https://vimeo.com/243625359
[embed_video] => https://player.vimeo.com/video/243625359
)
[1] => Array
(
[provider] => Vimeo
[title] => SampleVideo_1280x720_5mb
[description] => We spend our days building a product we love for a growing community of millions. And eating lots of free snacks.
[description_nl2br] => We spend our days building a product we love for a growing community of millions. And eating lots of free snacks.
[thumbnail] => http://i.vimeocdn.com/video/667575091_640.jpg
[video] => https://vimeo.com/243438242
[embed_video] => https://player.vimeo.com/video/243438242
)
)
很好。我手动应用了我的视频链接,但正确的方法是动态应用我的视频链接。我想在基于 api 密钥中获取我的 vimeo 视频网址。
【问题讨论】: