簡體   English   中英

找不到PHP錯誤類別'Google_Http_Request'

[英]PHP Error Class 'Google_Http_Request' not found

我正在嘗試從Google雲端硬盤下載或轉換文件。 我正在使用以下代碼,但出現錯誤“找不到類'Google_Http_Request'”。 我似乎找不到我所缺少的東西。 我想念什么嗎? 需要文件嗎?

我正在使用php-google-api-php-client(0.6.2-1)[universe]。

謝謝。

$file = $service->files->get($drive_id);
        //if actual file
        //$downloadUrl = $file->getDownloadUrl();
        //if a google doc
        $downloadUrl = $file->getExportLinks();


        if ($downloadUrl) {
            $request = new Google_Http_Request($downloadUrl, 'GET', null, null);
            $httpRequest = $service->getClient()->getAuth()->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;
        }

通常,php不會自動加載任何類。 從根本Google_Http_Request ,您將需要require()正確的文件來加載Google_Http_Request ,但是由於Google驅動器api需要身份驗證,因此您會遇到更多問題。

我建議您遵循Google開發者中心上提供的更新的指導: https : //developers.google.com/drive/web/quickstart/php 快速入門甚至可以列出文件。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM