php readfile 不适用于 Google Drive


php readfile not working with Google Drive

我试图制作一个php脚本,用于下载同意我的Google云端硬盘,并使用此脚本为我的网站提供服务。我尝试在本地主机上使用,但发生错误,无法流式传输读取文件错误行号 xx请帮忙。

代码:

    $CLOUD      =   'http://googledrive.com/host/0B7vvcajRaUZhaThKdi1MNnAwVGc/';
    $fileREQ    =   '';
    if(isset($_GET['fname'])) {
    $fileREQ    =   $_GET['fname'];
    }
    $rand       =   rand(11, 99).$fileREQ.'.zip';
    $ORG        =   $CLOUD.$fileREQ;
//Below code for force to browser display save as dialogue box options;
header('Content-type: application/zip');
//Below code for rename the source file name to escape hot-linking;
header('Content-Disposition: attachment; filename='.$rand);
//Below code for Sending correct file size to be ready to Download;
header('Content-Length: '.filesize($CLOUD.$fileREQ));
//Below code for read original file from the source;
readfile($CLOUD.$fileREQ);

错误:

Warning: readfile(googledrive.com/host/0B7vvcajRaUZhaThKdi1MNnAwVGc/Scanned Applications.zip) [function.readfile]: failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request in C:'wamp'www'$$ avleen-php'GOOGLE_DRIVE'G-DRIVE.php on line 24
Warning: filesize() [function.filesize]: stat failed for googledrive.com/host/0B7vvcajRaUZhaThKdi1MNnAwVGc/Scanned Applications.zip in C:'wamp'www'$$ avleen-php'GOOGLE_DRIVE'G-DRIVE.php on line 21

您需要 Google Drive API 来执行此操作。
有关 API 的更多信息,请参阅 https://developers.google.com/drive/v2/reference/#Files