Am trying download a google drive files to a directory using the code below. when I run the code it only open the content of the file on the browser as per code below
// authentication google drive goes here
$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();
Here is how am trying to download it to a directory called destinations
// Open file handle for output.
$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";
here is the error i got
Fatal error: Uncaught Error: Call to a member function eof() on string in C:\xampp\htdocs\download.php