我尝试使用此方法下载文件
/**
* Download a file's content.
*
* @param Google_DriveService $service Drive API service instance.
* @param File $file Drive File instance.
* @return String The file's content if successful, null otherwise.
*/
function downloadFile($service, $file) {
$downloadUrl = $file->getDownloadUrl();
if ($downloadUrl) {
$request = new Google_HttpRequest($downloadUrl, 'GET', null, null);
$httpRequest = Google_Client::$io->authenticatedRequest($request);
if ($httpRequest->getResponseHttpCode() == 200) {
return $httpRequest->getResponseBody();
} else {
// An error occurred.
return null;
}
} else {
// The file doesn't have any content stored on Drive.
return null;
}
}
在那里找到:https://developers.google.com/drive/v2/reference/files/get
但是我不知道在图书馆的哪个地方我可以找到我需要包含的那两个类:
- 的 Google_HttpRequest
- 的 Google_Client