我尝试使用谷歌服务帐户访问和预览来自我的谷歌硬盘的视频,当我登录我的谷歌帐户时它完美无缺,但我需要它能够预览视频即使我没有登录。例如,当我在私人窗口上调用它时,它会带来所有数据,id,名称,但预览模式不起作用。你们有什么想法我能做些什么来解决它?
谢谢。
test.php文件:
require_once '/vendor/autoload.php';
putenv('GOOGLE_APPLICATION_CREDENTIALS=Drive.json');
$client = new Google_Client();
$client->addScope(Google_Service_Drive::DRIVE);
$client->useApplicationDefaultCredentials();
$client->setSubject($mySubject);
$service = new Google_Service_Drive($client);
$response = $service->files->listFiles(array(
'q' => "name='test.mp4'",
'spaces' => 'drive',
'fields' => 'nextPageToken, files(id, name)',
));
$file = $response->files[0];
printf("Arquivo: %s (%s)\n", $file->name, $file->id);
$url = "https://drive.google.com/file/d/". $file->getId() ."/preview";
?>
<iframe src="<?php echo $url ?>" width="100%" height="100%"></iframe>