I'd like to use the method vimeo.videos.getInfo to get the info on a private video uploaded to my account. I'll only ever use this application on one website, so I'm hard coding the access token into the code.
I'm using the official PHP library for the Vimeo API (https://github.com/vimeo/vimeo.php).
So here's what I have so far...
$vimeo = new Vimeo($apiKey, $apiSecret, $accessToken);
All good. At first, when I tried the sample code from the example:
$user_data = $vimeo->request('/me');
print_r($user_data);
That returned an empty array:
Array (
[body] =>
[status] => 0
[headers] => Array
(
)
)
I noticed they mentioned if the array is returning empty, it probably had something to do with an invalid SSL certificate. Right now, I'm just developing on localhost, so I set CURLOPT_SSL_VERIFYPEER to false (thanks to these instructions: http://unitstep.net/blog/2009/05/05/using-curl-in-php-to-access-https-ssltls-protected-sites/). I added it to the array on line 112 in vimeo.php:
$curl_opt_defaults = array(
CURLOPT_HEADER => 1,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 30,
CURLOPT_SSL_VERIFYPEER => false);
As soon as I did that, I was able to return the information about the authenticated user.
But this still is returning an empty array:
$params = array(
'video_id' => 95307197
);
$videos = $vimeo->request('vimeo.videos.getInfo', $params);
print_r($videos);
Same with any methods I try to put in there. Did I do the CURLOPT_SSL_VERIFYPEER thing wrong or is something else wrong with my syntax?
Thanks to this example I solved the same issue, in the current api at _request method(line 125) add the curl option CURLOPT_SSL_VERIFYPEER and set it to false so you will have an array like this:
and that's all :) hope this helps someone else.
I thought that I might share my solution which took me some time to figure out. I also wanted to access private video data, namely the number pf time the video played. Here are my steps:
Client Identifier
,Client Secret
, and generate anAccess Token
with the propertiesPublic
,Private
, andInteract
. You may need to add or remove properties based on your access need.$name = array_slice(explode("/", $file_path), -1)[0];
to solve it remove the[0]
at the end! In fact I didn't need to call this function to know if it did any harm, but this solved my problem. Am on Dreamweaver by the way.curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
before every$response = curl_exec($curl);
statement. This should be 3 additions.Here is my Code:
In my case I did
echo
for the number of plays only, but you can print the whole body. Hope this helps someone too.Hopefully this helps someone else. The Vimeo API documentation is all out of whack and the new API docs link back to the older API docs, which only adds to the confusion.
The new API doesn't use the methods from the Advanced API, it uses the endpoints here https://developer.vimeo.com/api/endpoints
Here is the code that eventually worked for me: