3

I have a Vimeo PRO account with a bunch of videos, and what I want is use PHP to retrieve the direct link to a video (so its mp4 file URL that you can get through the settings sections in Vimeo's website) providing the video ID.

I've already created a Vimeo app in Vimeo's developer site, so I have all the required credentials. But Vimeo's documentation is a nightmare and you end up jumping from link to link trying to find something in order to end up where you started...

I've found this example in SO but when I follow it I end up reaching a wall because the API it uses apparently doesn't work anymore, so in order to find out how to adapt it I use the current documentation, which takes me to the loophole mentioned above.

So, could anyone point me to (or provide) some real world code for what I'm trying to accomplish? It sounds like it should be pretty simple but I can't figure it out. The biggest issue I have is that all the examples I see are meant for accessing others videos, but I want access to mine.

I've been looking at the API's github page but I can't figure out how to initiate the API with my credentials and how to get a video's information providing its ID, I don't see an example for that.

Any help would be much appreciated!

Community
  • 1
  • 1
Albert
  • 1,516
  • 3
  • 24
  • 55

2 Answers2

4

I´m facing the same problems trying to get some real world code in order to learn how to use the new API.

Here are an example of how to get a VIDEO URL:

<?php

    require("includes/vimeo/autoload.php");
    use Vimeo\Vimeo;

    $client_id = 'Client Identifier';
    $client_secret = 'Client Secrets';
    $access_token = 'Token';

    $vimeo = new Vimeo($client_id, $client_secret, $access_token);
    $response = $vimeo->request("/videos/video_id");
    echo $response["body"]["link"];

?>  

Making an list from all videos of an album, sorted alphabetic, 50 per page (2 pages in this case, 83 videos):

<?php

    require("includes/vimeo/autoload.php");
    use Vimeo\Vimeo;

    $client_id = 'Client Identifier';
    $client_secret = 'Client Secrets';
    $access_token = 'Token';

    $vimeo = new Vimeo($client_id, $client_secret, $access_token);

    /* Get the list of videos in an Album */
    $pages = 2;
    for($i = 1; $i <= $pages; $i++) {
    $format = "/me/albums/3004651/videos?per_page=50&sort=alphabetical&page=" . $i;
    $response = $vimeo->request($format);
     foreach ($response['body']['data'] as $video) {
        echo str_replace("/videos/", "", $video['uri']);
        echo "<br />";
    }
 }  

?>  

More code examples would be good. Hope it helps.

Marco Floriano
  • 318
  • 2
  • 6
  • 14
1

We're working on improving the docs! In the next couple of months they are getting an overhaul to be more "feature" based and less "api" based.

In the meanwhile, PRO users have access to their own video files on every video response. Lists of videos in channels, lists of your videos, direct video links etc.

  1. Start by using the official PHP library: https://github.com/vimeo/vimeo.php
  2. Get your access token (through redirect for external Vimeo users, through the developer site for your own account) and put it into the library
  3. Your videos can be located through $videos = $lib->request('/me/videos');
  4. Find the file information (containing more than the url) at $videos['body']['data'][$array_index]['files']

For now I recommend writing a quick script and dumping out the list of files to help determine the rest of the logic. Make sure to pick your file based on the dimensions of the video, because HD could mean either 720 or 1080p.

Dashron
  • 3,968
  • 2
  • 14
  • 21
  • 1
    thank you for your response. Yeah an overhaul of the documentation is really needed, glad to hear you guys are working on that. About my question, would you be able to link some example (or provide it here) of PHP code as to how I create that connection to the API and how I make that call to receive all my files info? – Albert May 12 '15 at 17:04
  • Added more details to the answer. lmk if you have more questions! – Dashron May 13 '15 at 16:22
  • finally got this to work (specially useful was Marco's mention of **$vimeo->request("/videos/video_id");**, that's exactly what I needed. However, I get the error **Uncaught exception 'Vimeo\Exceptions\VimeoRequestException' with message 'Unable to complete request.[SSL certificate problem: unable to get local issuer certificate]'**, which points to line 154 of the Vimeo.php file. The only way to make the library work is by setting **CURLOPT_SSL_VERIFYPEER => false** on line 60 of Vimeo.php, but I guess that defeats the purpose of using SSL. Any other way to fix this? – Albert May 18 '15 at 23:10
  • The libraries troubleshooting section has some details: https://github.com/vimeo/vimeo.php#troubleshooting. It asks you to set some curl opts, which you can assign using this method: https://github.com/vimeo/vimeo.php/blob/master/src/Vimeo/Vimeo.php#L197. I'll update the docs to be clearer. – Dashron May 19 '15 at 13:08