Vimeo Thumbnails for private video in PHP

297 views Asked by At

I have tried every single answer on this forum and couldn't get a proper working code. So I am posting this again. I want to get the thumbnail of private and hidden Videos from Vimeo. I also have an access token generated which I tried to use with the solutions provided for the old questions which also didn't work.

I tried this code

https://vimeo.com/api/oembed.json?url=https://vimeo.com/531126552/access_token

Also tried using cURL


curl_setopt($curl_h, CURLOPT_HTTPHEADER,
    array(
        'Authorization: bearer {access_token}',
        'Accept: application/vnd.vimeo.*+json;version=3.4',
    )
);

curl_setopt($curl_h, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($curl_h);

The response for above cURL code is this:

{"error":"Something strange occurred. Please contact the app owners.","link":null,"developer_message":"No user credentials were provided.","error_code":8003}

Please suggest me a way to do this or help me find where the error is.

2

There are 2 answers

1
Martin Jacob On BEST ANSWER

The thumbnails can be accessed by the thumbnail_url in JSON data provided by Oembed API sample : https://vimeo.com/api/oembed.json?url=https://vimeo.com/{video_id}/

0
Debbie Kurth On

Here is what works for public videos. I know you asked about private, so I am going to ask, if you ever figured it out...ping me. Trying to figure out the same.

For others, here is the public solution. It is the private videos that it fails on.

function mmd_get_vimeo_info( $video_id ) 
 {
  // https://vimeo.com/api/oembed.json?url=https://vimeo.com/
  
  $VimeoConnectLink        = "https://vimeo.com/api/oembed.json?url=https://vimeo.com/" . $video_id ;   
  $request                 = wp_remote_get( esc_url_raw($VimeoConnectLink));
  if ('error' == $request || is_wp_error($request))
    return ""; 
    
  $response = wp_remote_retrieve_body( $request );
  if ('error' == $response || is_wp_error($response))
    return ""; 
    
  $video_array = json_decode( $response, true );
    
// Looking for [title], [thumbnail_url] [duration]
  return $video_array;
 }

But it can fail with domain privacy in place.