【问题标题】:Allow users to upload videos to my channel using youtube API v3允许用户使用 youtube API v3 将视频上传到我的频道
【发布时间】:2014-11-22 06:25:24
【问题描述】:

使用 Google API v3 php 库。我希望用户在我的 youtube 频道上上传视频。但是 oAuth 需要用户 google 登录并将视频上传到登录的用户 youtube 频道。

在使用V3 api之前,我们使用V2上传视频,效果很好。

global $youtube_api_key, $youtube_username, $youtube_password;

if(is_file('../uploader/ClassYouTubeAPI.php')){ include_once ('../uploader/ClassYouTubeAPI.php'); }
else{ include_once('ClassYouTubeAPI.php'); }

$obj = new ClassYouTubeAPI($youtube_api_key);
$result = $obj->clientLoginAuth($youtube_username, $youtube_password);
$result = $obj->uploadVideo($uploaded_file_name, $file_path, $title, $description, $privacy);
var_dump($result);
if (is_array($result) and count($result) and ! isset($result["is_error"])) {
    $youtube_file = str_replace($uploaded_file_name, $result["videoId"] . '.youtube', $file_path);
    $resource = fopen($youtube_file, 'w');
    fwrite($resource, "");


    fclose($resource);

    @unlink($file_path);

    return $result["videoId"];
} else {
    @unlink($file_path);
    return false;
}

有什么方法可以在没有“用户 Google 帐户”的情况下使用 V3 并将视频上传到我的频道?

【问题讨论】:

    标签: php youtube google-api youtube-api


    【解决方案1】:

    只有一种解决方案,描述为here

    简而言之,您必须在Google console 中创建一个“网络应用程序”帐户(而不是“服务帐户”),并代表您的 YouTube 帐户从您的服务器进行身份验证。

    【讨论】:

    • 这种方式上传的视频数量有限制吗?
    猜你喜欢
    • 2016-10-19
    • 2018-02-06
    • 2019-02-28
    • 2017-07-05
    • 2013-10-27
    • 2015-06-27
    • 2013-12-16
    • 2015-08-31
    • 2012-12-23
    相关资源
    最近更新 更多