私のウェブサイトでは、ユーザーが私の 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 を使用していますか?