Rohan Prabhu
Rohan Prabhu

Reputation: 7302

Making a vimeo API call from JavaScript

I have just not been able to make even a simple Vimeo API call using XHR, because I have not been able to generate the API Signature at all using just JavaScript. I have no clue how to go about this. Is there anyone who could provide me a simple example of how to call, let's say, video.search from just JavaScript. I have my API key and the secret, but making a simple call is seeming like a monumental task right now.

Regards, rohan

Upvotes: 4

Views: 7835

Answers (1)

jrue
jrue

Reputation: 2560

I don't believe you can use Vimeo's advanced API with only JavaScript. To do that, you need to authenticate with OAuth using a server-side language:

http://vimeo.com/api/docs/getting-started

Vimeo's JavaScript API allows you to do things like load a single video, or get information about a videos in JSON/XML. This doesn't include video.search unfortunately.

http://vimeo.com/api/docs/player-js

If you still want to use the JavaScript API, you need to turn the API on in the actual video by adding api=1. With an iframe, add it as a query string: http://player.vimeo.com/video/VIDEO_ID?api=1 or if using Flash, add it as a separate param tag <param name="flashvars" value="api=1" />.

Then just use document.getElementById() to start using the API. Method calls on their universal embed (iframe) gets a little tricky, because they only allow messages sent as a serialized JSON objects. I recommend using their Froogaloop javascript framework which handles most of this for you.

https://github.com/vimeo/player-api/tree/master/javascript

Vimeo also has a working example online.

Upvotes: 5

Related Questions