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
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
Share Improve this question asked Jul 30, 2011 at 23:23 Rohan PrabhuRohan Prabhu 7,3125 gold badges41 silver badges75 bronze badges 2- 1 If it's got a secret key then you shouldn't be using javascript. You would have to put the secret key in javascript, where anyone could get it. Do the request on your server. – evan Commented Jul 30, 2011 at 23:37
- I know of that issue, and I know why I MUST make this call from my server, but the problem is that this is a hack I'm doing for Open Hack India and I have exactly 10 hours 24 minutes to finish up this alongwith a lot of work. Shifting this to a server deployment would make things extremely difficult for now. – Rohan Prabhu Commented Jul 30, 2011 at 23:51
1 Answer
Reset to default 5I 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./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./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./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 remend using their Froogaloop javascript framework which handles most of this for you.
https://github./vimeo/player-api/tree/master/javascript
Vimeo also has a working example online.