【问题标题】:Youtube Data API v3 Failed to start the resumable uploadYoutube Data API v3 无法开始恢复上传
【发布时间】:2013-11-19 11:47:47
【问题描述】:

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

我已尝试将可恢复选项设置为 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"
 }

【问题讨论】:

    标签: php youtube youtube-api


    【解决方案1】:

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

    【讨论】:

    • “访问令牌”到底是什么意思? “服务器密钥”还不够吗?我也面临同样的问题。
    猜你喜欢
    • 1970-01-01
    • 2017-10-22
    • 2015-11-07
    • 1970-01-01
    • 2013-05-10
    • 2014-01-19
    • 1970-01-01
    • 1970-01-01
    • 2015-12-09
    相关资源
    最近更新 更多