【问题标题】:Youtube PHP API Upload a VideoYoutube PHP API 上传视频
【发布时间】:2015-11-19 10:07:36
【问题描述】:

我正在尝试使用 PHP API (V3) 将视频上传到 youtube。

我的问题: 我不想对特定用户进行身份验证,但让我的应用程序使用服务器密钥(而不是客户端 ID)并上传给拥有该应用程序的用户。

我的代码:

    $DEVELOPER_KEY = '';
    $APPNAME = "";
    $client = new Google_Client();
    $client->setDeveloperKey($DEVELOPER_KEY);
    $client->setScopes('https://www.googleapis.com/auth/youtube');
    $client->setApplicationName($APPNAME);
    $videoPath = "";
    $video = new Google_Service_YouTube_Video();

    $youtube = new Google_Service_YouTube($client);
    $insertRequest = $youtube->videos->insert("status,snippet", $video);

    // Create a MediaFileUpload object for resumable uploads.
    $media = new Google_Http_MediaFileUpload(
            $client, $insertRequest, 'video/*', null, true, 1 * 1024 * 1024
    );

错误:

需要用户登录

我不想使用客户端身份验证...没有涉及特定用户。 有没有办法仅验证服务器密钥(代表应用所有者)?

【问题讨论】:

    标签: php api authentication oauth-2.0 youtube-api


    【解决方案1】:

    尝试推迟身份验证调用:$client->setDefer(true);See the full example here(切换到 PHP 选项卡)。另外,请仔细检查开发人员密钥。它应该是server key。没有IP限制。或者仔细检查 ip 限制。

    【讨论】:

    • 你没有抓住重点......这正是我使用的,但我不想验证用户(这不相关,因为我只有一个应用程序)示例中的所有内容都基于用户令牌和服务器密钥不起作用
    • 只是为了验证自己,请打开this link in a browser。 XXX 是Server API key
    • 这有帮助吗? (结果):{“error”:{“errors”:[{“domain”:“youtube.parameter”,“reason”:“missingRequiredParameter”,“message”:“未选择过滤器。”,“locationType”:“参数”,“位置”:“”}],“代码”:400,“消息”:“未选择过滤器。” } }
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-05-25
    • 1970-01-01
    • 1970-01-01
    • 2012-12-23
    • 1970-01-01
    • 2014-09-27
    • 2019-08-27
    相关资源
    最近更新 更多