Laravel 从google drive中读取word文档内容

Laravel 从google drive中读取word文档内容,laravel,laravel-5,google-api,google-drive-api,Laravel,Laravel 5,Google Api,Google Drive Api,我正在尝试使用google sdk从google drive获取文档内容。问题是,get()函数工作不正常。它只提供文件元数据,不提供任何实际内容 $googl = new Googl(); $this->client = $googl->client(); $this->client->setAccessToken(session('user.token')); $this->drive = $googl->drive($this->client);

我正在尝试使用google sdk从google drive获取文档内容。问题是,
get()
函数工作不正常。它只提供文件元数据,不提供任何实际内容

$googl = new Googl(); 
$this->client = $googl->client();
$this->client->setAccessToken(session('user.token'));
$this->drive = $googl->drive($this->client);

$file = $this->drive->files->get("fileId"); 
return $file;

我怀疑这里可能有语言问题

从谷歌硬盘文件读取内容

GoogleDrive api是一个文件数据存储api。这意味着它存储文件本身以及关于该文件的信息。它不允许您访问该文件的内容

如果你想知道文件中有什么,你需要下载文件并在你的机器上打开它

或者尝试,但我怀疑它将只能读取谷歌驱动器文档文件,而不是word文件,您可能需要先转换它

下载文件

如果您查看文档,您将发现以下内容

 $fileId = '0BwwA4oUTeiV1UVNwOHItT0xfa2M';
$response = $driveService->files->get($fileId, array(
    'alt' => 'media'));
$content = $response->getBody()->getContents();
从中,您可以使用以下方式下载文件:

$file = $this->drive->files->get("fileId", array('alt' => 'media'));
$content = $file->getBody()->getContents();