使用Google API v3 php库。我希望用户上传视频到我的youtube频道。但oAuth要求用户谷歌登录,并将视频上传到已登录的用户youtube频道。
在使用V3接口之前,我们使用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;
}有没有办法在没有“用户谷歌帐户”的情况下使用V3并将视频上传到我的频道?
发布于 2014-11-17 19:58:45
只有一种解决方案,被描述为here。
简而言之,您必须在Google console中创建一个“YouTube应用程序”帐户(而不是“服务帐户”),并代表您的web帐户从服务器进行身份验证。
https://stackoverflow.com/questions/26073160
复制相似问题