如何通过 api 将视频上传到 Vimeo?

How to upload video to Vimeo through their api?

假设我的网站上有一个视频 url:它是这样的: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 让我有点困惑(可能所有其他开发人员开始使用他们的 api ).那么,根据您的经验,您能告诉我如何将此视频上传到那个 vimeo 并取回已上传的视频 url 吗?

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

Upload Access

Approved for the following accounts:
Your account

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

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

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

官方PHP图书馆: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

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

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