Youtube Data API v3无法启动可恢复上传

时间:2013-11-19 11:47:47

标签: php youtube youtube-api

截至今天上午,我在尝试使用服务帐户和密钥上传视频时收到此错误,这在昨天下午6点左右有效。

我已尝试将resumable选项设置为true和false但无效。

这是我的代码

$client = new Google_Client();
$client->setClientId($OAUTH2_CLIENT_ID);

$key = file_get_contents($KEY_FILE);

$client->setAssertionCredentials(new Google_AssertionCredentials(
    $SERVICE_ACCOUNT_NAME,
    array('https://www.googleapis.com/auth/youtube'),
    $key)
);


$client->setClientSecret($OAUTH2_CLIENT_SECRET);
$redirect = filter_var('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'],
    FILTER_SANITIZE_URL);
//$client->setRedirectUri($redirect);

$htmlBody = '';

// YouTube object used to make all API requests.
$youtube = new Google_YoutubeService($client);

我从此处取回有效的承载签名,但是当我启动上传时,我将非恢复标志设置为false时出现以下错误:

$media = new Google_MediaFileUpload('video/mp4', null, true, $chunkSizeBytes);

"error": {
  "errors": [
   {
    "domain": "youtube.header",
    "reason": "youtubeSignupRequired",
    "message": "Unauthorized",
    "locationType": "header",
    "location": "Authorization"
   }
  ],
  "code": 401,
  "message": "Unauthorized"
 }

1 个答案:

答案 0 :(得分:0)

我没有设置引用凭据的访问令牌。确保你设置了访问权限!