我的网站允许用户将视频上传到我的 youtube 帐户。要将我的应用程序连接到 Google (youtube),我使用了组件 ClientLogin,如下所示:
//my credentials
$user = 'mymail@gmail.com';
$pass = 'mypass';
$service = 'youtube';
$developerKey = 'mydevkey';
//create the http client
$httpClient = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, $service, null,
Zend_Gdata_ClientLogin::DEFAULT_SOURCE,null,null,
Zend_Gdata_ClientLogin::CLIENTLOGIN_URI,'GOOGLE');
$httpClient->setHeaders('X-GData-Key', 'key='. $developerKey);
//create the instances
$youTubeService = new Zend_Gdata_YouTube($httpClient);
$newVideoEntry = new Zend_Gdata_YouTube_VideoEntry();
$newVideoEntry->setVideoTitle("test video");
$newVideoEntry->setVideoDescription("just testing");
$newVideoEntry->setVideoCategory("Music");
$newVideoEntry->setVideoTags('test, api');
//call the API to get the upload url and token
$tokenHandlerUrl = 'https://gdata.youtube.com/action/GetUploadToken';
try {
$tokenArray = $youTubeService->getFormUploadToken($newVideoEntry, $tokenHandlerUrl);
} catch (Exception $e) {
}
$tokenValue = $tokenArray['token'];
$postUrl = $tokenArray['url'];
但是现在 ClientLogin 已被弃用:S,我需要使用 oAuth 2 ......但一直在阅读文档,它没有说明使用我的应用程序凭据(而不是用户的凭据)进行连接。有没有办法重现此代码但使用 oAuth?