从 JavaScript 进行 vimeo API 调用
我无法使用 XHR 进行简单的 Vimeo API 调用,因为我根本无法仅使用 JavaScript 生成 API 签名。我不知道该怎么做。有没有人可以为我提供一个简单的示例,说明如何仅从 JavaScript 调用 video.search。我有 API 密钥和秘密,但现在进行一个简单的调用似乎是一项艰巨的任务。
问候, 罗汉
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不相信您可以仅通过 JavaScript 使用 Vimeo 的高级 API。为此,您需要使用服务器端语言通过 OAuth 进行身份验证:
http://vimeo. com/api/docs/getting-started
Vimeo 的 JavaScript API 允许您执行诸如加载单个视频或获取有关 JSON/XML 视频的信息之类的操作。不幸的是,这不包括 video.search。
http://vimeo.com/api/docs/player-js
如果您仍然想要要使用 JavaScript API,您需要通过添加 api=1 在实际视频中打开 API。对于 iframe,将其添加为查询字符串:
http://player.vimeo.com/video/VIDEO_ID?api=1
,或者如果使用 Flash,请将其添加为单独的参数标记。
然后只需使用
document.getElementById()
即可开始使用 API。对其通用嵌入 (iframe) 的方法调用有点棘手,因为它们只允许消息 发送为序列化的 JSON 对象。我建议使用他们的 Froogaloop javascript 框架,它可以为您处理大部分工作。https://github.com/vimeo/player-api/tree/master/javascript
Vimeo 还在线提供了工作示例。
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.