问题
I was using the Vimeo simple API to display the videos from a channel on my website, but as you may know, it has a limit. I was wondering if you could give me an example of how to use the advanced API. I have read the documentation, But I just don't know how to use those methods (obviously i am not php expert).
So it would be awesome if you could show me one example or any tutorial were I could understand it.
This is Part of the code I was using in the simple API:
var apiEndpoint = 'http://vimeo.com/api/v2/';
var oEmbedEndpoint = 'http://vimeo.com/api/oembed.json'
var oEmbedCallback = 'switchVideo';
var videosCallback = 'setupGallery&iframe=false';
$(document).ready(function() {
$.getScript(apiEndpoint + vimeoUsername + '/videos.json?callback=' + videosCallback);
});
function setupGallery(videos) {
for (var i = 0; i < videos.length; i++) {
var html = '<li><a href="' + videos[i].url +'"alt="'+videos[i].title+'"><img src="' + videos[i].thumbnail_large + '" class="thumb" />';
html += '<div><p>' + videos[i].title + '</p></div></a></li>';
$('#thumbs ul').append(html);
}
I just want to do the same but with the advance API (using php).
thanks a lot, I'd appreciate any advise.
回答1:
[edit] NOTE: This is the old, advanced API. It is no longer supported by Vimeo, or accessible by new app developers. Please refer to the new upload documentation at https://developer.vimeo.com/api/upload/videos
- Create an Api APP at developer.vimeo.com/apps
- Use the official PHP library
Once you have that, you need to create your vimeo object
// You must replace CONSUMER_KEY and CONSUMER_SECRET with the values from your app
$vimeo = new phpVimeo('CONSUMER_KEY', 'CONSUMER_SECRET');
Once you have the vimeo object, you can make api calls using the call
method. This method takes an api method.
$videos = $vimeo->call('VIMEO_METHOD');
For your specific use case, finding the videos uploaded by a user, you use the method vimeo.videos.getUploaded
. You can find more documentation (and try it out!) at the vimeo api playground
Once you understand all of that, I believe the following code would work for you.
$vimeo = new phpVimeo('CONSUMER_KEY', 'CONSUMER_SECRET');
$videos = $vimeo->call('vimeo.videos.getUploaded', array('user_id' => $vimeo_username));
来源:https://stackoverflow.com/questions/17106097/how-to-use-vimeo-advanced-api-to-display-videos