我在这里使用Vimeo API: https://github.com/vimeo/vimeo.php
我已经将它包括在内:
// include the autoload file from the vimeo php library that was downloaded
include __DIR__ . '/vimeo/autoload.php';
// The client id and client secret needed to use the vimeo API
$clientId = "XXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$clientSecret = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
// when getting an auth token we need to provide the scope
// all possible scopes can be found here https://developer.vimeo.com/api/authentication#supported-scopes
$scope = array('public', 'private');
// initialize the vimeo library
$lib = new \Vimeo\Vimeo($clientId, $clientSecret);
// request an auth token (needed for all requests to the Vimeo API)
$token = $lib->clientCredentials($scope);
// redirect_uri must be provided, and must match your configured uri
$token = $lib->accessToken(code, redirect_uri);
// use the token
$lib->setToken($token['body']['access_token']);
然后我尝试获取视频拇指网址:
$vimeo_response = $lib->request('/videos/218234161/pictures', 'GET');
这只返回一个空值。
我不知道此时还有什么可以尝试。
答案 0 :(得分:0)
我最终通过在此处生成访问令牌来实现它: https://developer.vimeo.com/apps
一旦我获得了令牌以及客户端ID和秘密,这就是代码:
// include the autoload file from the vimeo php library that was
include __DIR__ . '/vimeo/autoload.php';
use Vimeo\Vimeo;
function get_vimeo_thumb($vimeo_video_id){
// The client id and client secret needed to use the vimeo API
$clientId = "XXXXXXXXXXXXXXXXXXXXXXX";
$clientSecret = "XXXXXXXXXXXXXXXXXXXXXXXXX";
$access_token = "XXXXXXXXXXXXXXXXXXXXXXXXX";
//// initialize the vimeo library
$vimeo = new Vimeo($clientId, $clientSecret);
// Set access token
$vimeo->setToken($access_token);
$thumb = $vimeo->request("/videos/" . $vimeo_video_id . "/pictures/");
return $thumb['body']['data'][0]['sizes'][2]['link'];
}