Vimeo API: 无法删除,因为官方 SDK 使用错误 url

Vimeo API: cannot delete because official SDK is using a wrong url

环境

目标

给定一个 vimeo 内容 url,删除视频。例如:有一个视频https://vimeo.com/12345678我想删除id为12345678

的视频

我在做什么

1.实例化 php sdk api 客户端

$client = new Vimeo(
   config('dyamer.vimeo_client_id'),
   config('dyamer.vimeo_client_secret'),
   config('dyamer.vimeo_access_token')
);

This configs are right, I'm using to upload videos and all works

2。调用删除api端点

$uri="https://vimeo.com/12345678";
$response = $client->request($uri, [], 'DELETE');

异常

最后一行代码抛出一个荒谬的异常:

[Could not resolve host: api.vimeo.comhttps] 
in /...project_folder.../vendor/vimeo/vimeo-api/src/Vimeo/Vimeo.php:527
Stack trace:
#0 /...project_folder.../vendor/vimeo/vimeo-api/src/Vimeo/Vimeo.php(149): Vimeo\Vimeo->_request('https://api.vim...', Array)

The last row is litterally showed with url trunced, it's not my fault on copy/pasting, but I think this demonstrate that something is wrong inside Vimeo SDK

问题

旁注

我已经打开了一个issue on Gihhub,没有任何sdk开发者的官方回复。

我成功地将错误追踪到我的

的一个错误

这是被控的片段actually on github here


            case 'DELETE':
                if ($json_body && !empty($params)) {
                    $headers['Content-Type'] = 'application/json';
                    $body = json_encode($params);
                } else {
                    $body = http_build_query($params, '', '&');
                }
                $curl_url = self::ROOT_ENDPOINT . $url;
                $curl_opts = array(
                    CURLOPT_POST => true,
                    CURLOPT_CUSTOMREQUEST => $method,
                    CURLOPT_POSTFIELDS => $body
                );
                break;

倾倒 $curl_url 我明白了

https://api.vimeo.comhttps://vimeo.com/12345678

显然是错误的。

来自official api doc about DELETE

REQUEST

DELETE https://api.vimeo.com/videos/{video_id}

所以错误完全是我的

错误

$uri="https://vimeo.com/12345678";
$response = $client->request($uri, [], 'DELETE');

$uri="videos/12345678";
$response = $client->request($uri, [], 'DELETE');

Sorry, Vimeo staff, it was my fault, not yours.