0

我使用了 Drive 的PHP 下载 api,但是当我调用它时,它什么也没做:$httpRequest=downloadFile($service, $file);- downloadUrl 不为空。

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;
  }
}

如何从 Google Drive 正确下载文件?

4

0 回答 0