How to get video streams by video id from my own Vimeo account
I have a Vimeo PRO account with a bunch of videos and I want to use PHP to get a direct link for the video (so the url of the mp4 file that you can get through the settings sections on the Vimeo website) providing the video ID .
I have already created a Vimeo app on the Vimeo developer site, so I have all the required credentials. But Vimeo documentation is a nightmareand you end up jumping from link to link trying to find something to end up where you started ...
I found this example on SO, but when I follow it, I end up accessing the wall because the API it uses doesn't seem to work anymore, so in to find out how to adapt it. I am using the current documentation which leads me to the loophole mentioned above.
So, can someone point me to (or provide) some real world code for what I am trying to accomplish? It looks like it should be pretty simple, but I can't figure it out. The biggest problem I have is that all the examples I see are for accessing other videos, but I want to access mine.
I've looked at the API github page but I can't figure out how to initiate the API with my credentials and how to get the video information providing its ID, I don't see an example for this.
Any help would be greatly appreciated!
source to share
I am facing the same problems trying to get real world code to learn how to use the new API.
Here's an example of how to get the 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"];
?>
Creating a list of all videos in the album, sorted alphabet, 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 />";
}
}
?>
Other code examples would be nice. Hope it helps.
source to share
We are working on improving the documentation! They are getting a major overhaul in the next couple of months to be more "functional" based and less "api".
Meanwhile, PRO users have access to their video files in the video meeting everyone . Channel video lists, your video lists, direct video links, etc.
- Start by using the official PHP library: https://github.com/vimeo/vimeo.php
- Get an access token (via a redirect for external Vimeo users through the developer site for their own account) and put it in the library
- Your videos can be located via
$videos = $lib->request('/me/videos');
- Find file information (containing more than url) in
$videos['body']['data'][$array_index]['files']
I currently recommend writing a quick script and dumping the list of files to define the rest of the logic. Be sure to select a file based on the video sizes, because HD can mean either 720 or 1080p.
source to share