我的網站允許用戶上傳視頻到我的youtube帳戶。要連接我aplication谷歌(YouTube)的我使用的成分ClientLogin的是這樣的:谷歌OAuth和Zend連接使用我的應用程序的憑據
//my credentials
$user = '[email protected]';
$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?
我也試圖找到一個解決方案(至少是ClientLogin的消失之前!)爲了這。你是如何設法完成的? – s3v3n 2012-11-07 01:56:16
現在我必須這樣做。我已經讀到ClientLogin仍然會[2015年之前可用](https://developers.google.com/accounts/terms),所以現在我猜,沒關係,直到我找到更好的解決方案 – pleasedontbelong 2012-11-07 09:31:35
是的,我猜信息是正確的:https://developers.google.com/accounts/terms。非常感謝你! – s3v3n 2012-11-07 16:14:57