将google api客户端添加到codeigniter

Sat*_*man 5 php codeigniter google-drive-api google-api-php-client

我想在codeigniter中使用php上传文件到谷歌驱动器.首先,我正在尝试将google api客户端集成到codiginator.

我已将所有文件上传到我的third_party文件夹中.它看起来像这样

在此输入图像描述

google.php在我的libraries文件夹中创建了一个文件

google.php文件

        <?php
        if (!defined('BASEPATH')) exit('No direct script access allowed');
        set_include_path(APPPATH . 'third_party/' . PATH_SEPARATOR . get_include_path());
        require_once APPPATH . 'third_party/Google/Client.php';

        class Google extends Google_Client {
            function __construct($params = array()) {
                parent::__construct();
            }
        } 

        ?>
Run Code Online (Sandbox Code Playgroud)

然后我像这样在我的家庭控制器中加载了库

        function __construct() {
            parent::__construct();

          //session, url, satabase is set in auto load in the config
            $this->load->model('Home_model', 'home');
            $this->load->library('pagination');
            $this->load->library('google');

        }
Run Code Online (Sandbox Code Playgroud)

加载谷歌库后,家庭控制器内的所有功能都无法正常工作.每件事只显示一个空白页面.

在家庭控制器内部我有一个'test_lib'功能

    function test_lib(){

        echo $this->google->getLibraryVersion(); 
   }
Run Code Online (Sandbox Code Playgroud)

当我加载页面.我得到一个黑页没有错误或显示.

有人可以帮助我将google api客户端库添加到codeigniter.TNX.

Tpo*_*jka 6

正如我之前提到的,Google/autoload.php在使用类/实例化对象之前,应该包含以下存储库中的示例 .在你的情况下它是APPPATH . 'third_party/Google/autoload.php'文件.