2017-07-03 30 views
0

我使用Vimeo的API在這裏: https://github.com/vimeo/vimeo.phpVimeo的PHP API - 使身份驗證的請求

我已經包括像這樣:

// 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'); 

這只是返回一個空值。

我不知道還有什麼要嘗試在這一點上。

+1

的兩個參數'accessToken'方法是常量? –

+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']; 

    }