Vimeo:如何使用php官方客户端为视频添加域名白名单?

Vimeo: how to use php official client to add a domain whitelist for a video?

我正在使用官方 Vimeo PHP 客户端。

可以上传视频,设置privacy.embedwhitelist

然后医生告诉我:

To add a domain to the whitelist, send a PUT request to /videos/{video_id}/privacy/domains/{domain}.

我试过了

$privacy_uri = $uri . "/privacy/domains/testdomain.tld";
$domain_add_response = $client->request($privacy_uri);

在哪里 - $uri/vimeo/<video_id> - $client 出生于 new Vimeo(CLIENT_ID, CLIENT_SECRET, VIMEO_TOKEN);

问题

打印 $domain_add_response 我得到一个 405 错误,可能是因为 Allow(请参阅以下响应转储)

Array
(
    [body] => 
    [status] => 405
    [headers] => Array
        (
            [Server] => nginx
            [Content-Type] => application/json
            [Allow] => PUT,DELETE,OPTIONS
            [X-Vimeo-DC] => ge
            [Accept-Ranges] => bytes
            [Via] => 1.1 varnish
            [Content-Length] => 0
            [Date] => Mon, 15 Apr 2019 08:30:47 GMT
            [Connection] => keep-alive
            [X-Served-By] => cache-bwi5125-BWI, cache-mxp19820-MXP
            [X-Cache] => MISS, MISS
            [X-Cache-Hits] => 0, 0
            [X-Timer] => S1555317047.232635,VS0,VE148
            [Vary] => Accept-Encoding
        )

)

我想我必须在我的请求中设置 PUT 方法,但是......如何?

查看 api 源代码找到解决方案:https://github.com/vimeo/vimeo.php/blob/master/src/Vimeo/Vimeo.php#L88

其中request的签名是

public function request($url, $params = array(), $method = 'GET', $json_body = true, array $headers = array()): array

我知道我可以解决这个问题,只需传递一个空的 $params 数组并指定 PUT 作为请求 $method

我改变了这一行

$domain_add_response = $client->request($privacy_uri);

进入这个表格

$domain_add_response = $client->request($privacy_uri, [], 'PUT');

它按预期工作