Answer the question
In order to leave comments, you need to log in
How to download files from google drive using PHP?
I am guided by examples here: https://developers.google.com/drive/v3/web/quickst...
And here: https://developers.google.com/drive/v3/web/manage-...
List of files Already removed from the disk, you need to make it possible to download. But here's where it got tricky.
I set the access rights to the widest: https://www.googleapis.com/auth/drive
I'm trying to get the file as follows (Yii2 project):
public function actionDownload($fileId)
{
$service = GoogleDocsConsole::getService(); // Экземпляр Google_Service_Drive
$response = $service->files->export($fileId, 'application/pdf', [
'alt' => 'media'
]);
$content = $response->getBody()->getContents();
return $content;
}
Google_Service_Exception
{
"error": {
"errors": [
{
"domain": "global",
"reason": "insufficientPermissions",
"message": "Insufficient Permission"
}
],
"code": 403,
"message": "Insufficient Permission"
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question