我正在尝试使用下面的代码将谷歌驱动器文件下载到目录。当我运行代码时,它只按照下面的代码在浏览器上打开文件的内容
// 验证谷歌驱动器到这里
$file = $service->files->get($fileId);
$downloadUrl = $file->getDownloadUrl();
$request = new Google_Http_Request($downloadUrl, 'GET', null, null);
$httpRequest = $service->getClient()->getAuth()->authenticatedRequest($request);
echo $content= $httpRequest->getResponseBody();
这是我如何尝试将其下载到名为目标的目录
// 打开文件句柄输出。
$content = $service->files->get($fileId, array("alt" => "media"));
// Open file handle for output.
$handle = fopen("/download", "w+");
// Until we have reached the EOF, read 1024 bytes at a time and write to the output file handle.
while (!$content->eof()) {
fwrite($handle, $content->read(1024));
}
fclose($handle);
echo "success";
这是我得到的错误
致命错误:未捕获的错误:调用 C:\xampp\htdocs\download.php 中字符串的成员函数 eof()
UYOU