用户可以在经过身份验证或未经身份验证的情况下在单个 Youtube 频道上上传视频

Users can Upload video on single Youtube Channel with or without authentication

我正在制作一个程序,任何用户都可以将视频上传到我的 YouTube 频道。但它会产生错误。我的代码如下:-

   require_once 'Zend/Loader.php';
   Zend_Loader::loadClass('Zend_Gdata_YouTube');
   Zend_Loader::loadClass('Zend_Gdata_AuthSub');
   Zend_Loader::loadClass('Zend_Gdata_App_Exception');

   Zend_Loader::loadClass('Zend_Gdata_ClientLogin');

   $authenticationURL= 'https://www.google.com/accounts/ClientLogin';

   $client = "";

    $email = 'theprofessional1992@gmail.com';

  $passwd = '*******************';

   try {

     $client = Zend_Gdata_ClientLogin::getHttpClient($email, $passwd, 'cl');

   } catch (Zend_Gdata_App_CaptchaRequiredException $cre) {

echo 'URL of CAPTCHA image: ' . $cre->getCaptchaUrl() . "\n";
echo 'Token ID: ' . $cre->getCaptchaToken() . "\n";

 } catch (Zend_Gdata_App_AuthException $ae) {

echo 'Problem authenticating: ' . $ae->exception() . "\n";

}

Error :- Notice: Undefined offset: 1 in C:\wamp\www\Yt\zdata\demos\Zend\Gdata\YouTubeVideoApp\Zend\Gdata\ClientLogin.php on line 150

连我都不知道这个功能是怎么做出来的

请帮忙?

Note: The YouTube Data API (v2) has been officially deprecated as of March 4, 2014

对于 YouTube 数据 API (v3),您无法使用用户名和密码上传。
如果你想上传视频到 youtube,你必须使用这些库:
https://github.com/google/google-api-php-client
https://github.com/youtube/api-samples/tree/master/php
https://github.com/youtube/api-samples/blob/master/php/resumable_upload.php

当然,如果您不想在每个上传过程中都进行身份验证,则可以使用刷新令牌。

$client = new Google_Client();
$client->setClientId($OAUTH2_CLIENT_ID);
$client->setClientSecret($OAUTH2_CLIENT_SECRET);
$client->setScopes('https://www.googleapis.com/oauth2/v3/token');
$client->setAccessType('offline');

刷新令牌将包含在 api 响应中。将其保存到数据库中。请记住,您只能在第一次获得刷新令牌。如果丢失,您将不得不撤销您的申请 https://security.google.com/settings/security/permissions?pli=1

现在有了刷新令牌,您可以随时自动获取访问令牌:

$client->refreshToken($refreshToken);
$accessToken = $client->getAccessToken();