-2
나는 YouTube 동영상의 자막을 얻기 위해 노력하고 있어요하지만 난 REST.php 라인 (118)이 오류유튜브 API 오류 로그인이 필요 PHP
Google_Service_Exception을 가지고 :이은 필수
로그인 내 코드
function getCaptions($app, $developKey, $OAUTH2_CLIENT_ID, $OAUTH2_CLIENT_SECRET){
$client = new Google_Client();
$client->setApplicationName($app);
$client->setDeveloperKey($developKey);
$client->setClientId($OAUTH2_CLIENT_ID);
$client->setClientSecret($OAUTH2_CLIENT_SECRET);
$client->setScopes('https://www.googleapis.com/auth/youtube.force-ssl');
$client->setScopes('https://www.googleapis.com/auth/youtube');
$redirect = filter_var('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'],
FILTER_SANITIZE_URL);
$client->setRedirectUri($redirect);
// Define an object that will be used to make all API requests.
$youtube = new Google_Service_YouTube($client);
$captions = $youtube->captions->listCaptions('snippet',$video);
if (empty($captions)) {
$htmlBody .= "<h3>Can't get video caption tracks.</h3>";
} else {
$firstCaptionId = $captions[0]['id'];
$this->downloadCaption($youtube, $firstCaptionId, $htmlBody);
}
return response()->json($searchResponse->items[0]->snippet);
}
function downloadCaption(Google_Service_YouTube $youtube, $captionId, &$htmlBody) {
// Call the YouTube Data API's captions.download method to download an existing caption.
$captionResouce = $youtube->captions->download($captionId, array(
'tfmt' => "srt",
'alt' => "media"
));
$htmlBody .= "<h2>Downloaded caption track</h2><ul>";
$htmlBody .= sprintf('<li>%s</li>',
$captionResouce);
$htmlBody .= '</ul>';
}
나는 인증 ($client->authentication($code);
을) 할 내가 코드를 필요로 알고 있지만, 내가 그 코드를 얻을 수있는 모르겠어요.
업데이트를 원하십니까? – noogui