如何通过他们的 api 将视频上传到 Vimeo? [英] How to upload video to Vimeo through their api?

查看:53
本文介绍了如何通过他们的 api 将视频上传到 Vimeo?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我的网站上有一个视频网址:它是这样的:http://example.com/videos/myvideo.mp4 .我想使用自动(拉")上传方法将此视频上传到 vimeo.然后我只想在我的网站上托管它.问题是他们提供的文档让我有点困惑(可能还有其他所有开发人员开始使用他们的 api).那么,根据您的经验,您能告诉我如何将此视频上传到该 vimeo 并取回已上传的视频网址吗?

Let's imagine that I have a video url on my site: it's like this: http://example.com/videos/myvideo.mp4 . I want to use Automatic ("pull") uploads method to upload this video to vimeo. Then I simply want to host it on my site. The problem is that the documentation that they provide is kinda confusing to me (and possibly all other developers getting started with their api). So, from your experience can you tell me how to upload this video to that vimeo and get back the video url that has been uploaded?

我按照他们的说法创建了 vimeo 应用程序,并且我已请求上传访问权限.它说:

I created the vimeo app as they said and I have requested the upload access. It says:

Upload Access

Approved for the following accounts:
Your account

所以基本上一切都设置好了.我只需要知道应该向 vimeo 服务器发送什么 http 请求,以便上传可在网络上访问的 mp4 文件.

So basically everything is setup. I just need to know what http request should I send to the vimeo server in order to upload that mp4 file that is accessible on the web.

推荐答案

HTTP 请求在文档的拉取上传部分有详细说明:https://developer.vimeo.com/api/upload/videos#automatic-pull-uploads

The HTTP request is detailed in the pull upload section of the documentation: https://developer.vimeo.com/api/upload/videos#automatic-pull-uploads

https://api.vimeo.com/me/videos 的 HTTP POST 请求通过请求正文发送两个必需参数和一个可选参数.

An HTTP POST request to https://api.vimeo.com/me/videos with two required, and one optional parameter sent through the request body.

官方 PHP 库:https://github.com/vimeo/vimeo.php将帮助您发出上传请求,有关使用此库发出请求的文档位于此处:https://github.com/vimeo/vimeo.php#make-requests

The official PHP library: https://github.com/vimeo/vimeo.php will help you make the upload request, and documentation on making requests using this library is located here: https://github.com/vimeo/vimeo.php#make-requests

一旦你把所有的部分放在一起,请求看起来像这样:

Once you have all the pieces together, the request looks kind of like this:

$response = $lib->request('/me/videos', ['type'=>'pull','link'=>$url], 'POST');

这篇关于如何通过他们的 api 将视频上传到 Vimeo?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆