dongtou2016 2015-09-21 15:57
浏览 50

找不到PHP错误类'Google_Http_Request'

I'm trying to download or convert a file from Google Drive. I am using the below code, and I get the error "Class 'Google_Http_Request' not found". I can't seem to find what I'm missing. Am I missing something? A required file?

I'm using php-google-api-php-client (0.6.2-1) [universe].

Thanks.

$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;
        }
  • 写回答

1条回答 默认 最新

  • doubaran2438 2015-09-21 16:11
    关注

    In general, php does not autoload any classes. In basic terms, you would need to require() the right file to load Google_Http_Request, but you will run into more issues as google drive api requires authentication.

    I suggest you follow much newer instructions provided on the Google's Developer Center: https://developers.google.com/drive/web/quickstart/php. The quickstart even goes as far as list files.

    评论

报告相同问题?

悬赏问题

  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算
  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据