用PHP传递正文头

时间:2019-05-22 07:22:20

标签: php api vimeo vimeo-api

我正在按照以下指南制作Vimeo-API以上传字幕/标题:https://developer.vimeo.com/api/upload/texttracks#uploading-a-text-track-step-3

指南给出了4个步骤,我在第3步中陷入了停滞。

步骤3: To upload the text track, take the value of the link field from Step 2, and make a PUT request to this location: PUT https://api.vimeo.com{link}

这是我的代码:

require 'Vimeo/autoload.php';
use Vimeo\Vimeo;

$client = new Vimeo("xxxxxxxxxxxxxxxxxxxxxx,xxxxxxxxxxxxxxxxxx,xxxxxxxxxxxxx");


include __DIR__ . '/Vimeo/autoload.php';

$clientId = "xxxxxxxxxxxxxxxxxxxxx";
$clientSecret = "xxxxxxxxxxxxxxxxxxxxxxxx";
$scope = "public";
$userId = 9999999;
$lib = new \Vimeo\Vimeo($clientId, $clientSecret);
$token = $lib->clientCredentials($scope);


$lib->setToken('xxxxxxxxxxxxxxxxxxxxxxxxxxxxx');


$videos = $lib->request("/videos/99999999/texttracks", ["type"=>"captions", "language"=>"pt-BR", "name"=>"legenda"], "POST");
$link = $videos["body"]["link"];
$videos = $lib->request("/videos/99999999/texttracks/", ["link"=>$link, "body"=>"https://paste.ee/r/E3Q1K/0"], "PUT");

echo "<pre>".var_export($videos, true)."</pre>";

输出:

array (
  'body' => NULL,
  'status' => 405,
  'headers' => 
  array (
    'Server' => 'nginx',
    'Content-Type' => 'application/json',
    'Allow' => 'GET,POST,OPTIONS',
    'X-Vimeo-DC' => 'ge',
    'Accept-Ranges' => 'bytes',
    'Via' => '1.1 varnish',
    'Content-Length' => '0',
    'Date' => 'Wed, 22 May 2019 07:11:58 GMT',
    'Connection' => 'keep-alive',
    'X-Served-By' => 'cache-bwi5150-BWI, cache-lax8642-LAX',
    'X-Cache' => 'MISS, MISS',
    'X-Cache-Hits' => '0, 0',
    'X-Timer' => 'S1558509118.323164,VS0,VE80',
    'Vary' => 'Accept-Encoding',
  ),
)   

因此,此行中出现问题 $videos = $lib->request("/videos/99999999/texttracks/", ["link"=>$link, "body"=>"https://paste.ee/r/E3Q1K/0"], "PUT"); 如您所见,输出bodyNULL。如何正确设置正文标题?我正在尝试使该API持续三天,这是我的最后希望,如果您能帮助我,我将非常高兴。

谢谢

0 个答案:

没有答案