2

내 웹 사이트를 통해 내 YouTube 계정에 동영상을 업로드 할 수 있습니다.Google 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를 사용할 필요가 ...하지만 설명서를 읽고하고이 같은 구성 요소 ClientLogin을 사용 구글 (유튜브) 내 aplication를 연결하려면 내 앱 자격증 명 (사용자 자격 증명 아님)을 사용하여 연결하는 것에 대해서는 아무 것도 말하지 않습니다. 이 코드를 재현하는 방법은 없지만 oAuth를 사용하고 있습니까?

+0

(ClientLogin에 멀리 가기 전에 최소한!) 이것 때문에. 어떻게 그 일을 처리 했습니까? – s3v3n

+0

나는 이것을 이렇게해야만했다. 나는 ClientLogin이 여전히 [2015 년까지 사용 가능할 것입니다] (https://developers.google.com/accounts/terms)이므로 더 나은 솔루션을 찾을 때까지는 괜찮습니다. – pleasedontbelong

+0

그래, 그런 것 같아. https://developers.google.com/accounts/terms. 고마워요! – s3v3n

답변

1

이론적으로 OAuth2를 함께 할 수있는 방법은 서비스 계정입니다 : 계정이 당신의 API 콘솔에 설정되어

https://developers.google.com/accounts/docs/OAuth2ServiceAccount

되면, 그 다음 서버 간 상호 작용이 가능합니다. 불행하게도, 아직 서비스를 지원하지 않는 유튜브 API는 계정 :

https://code.google.com/p/google-api-php-client/wiki/OAuth2#Service_Accounts

희망이 지원이 곧 올 것이다 나는 또한 해결책을 찾기 위해 노력하고

+0

고마워요. 나는 그것을 희망한다. – pleasedontbelong

관련 문제