Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding google api client to codeigniter

I want to upload files to google drive using php in codeigniter. First of all i am trying to integrate google api client to codiginator.

I have uploaded all the files in to my third_party folder. it look like this

enter image description here

I i have created a file called google.php inside my libraries folder

google.php file

        <?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();
            }
        } 

        ?>

Then i loaded the library in my home controller like this

        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');

        }

After loading the google library none of the functions inside home controllers are working. Every thing just shows a blank page.

And Inside the home controller i have a function 'test_lib'

    function test_lib(){

        echo $this->google->getLibraryVersion(); 
   }

When i load the page . i get a black page no errors or showing.

Can someone help me to add the google api client library to codeigniter. Tnx.

like image 655
Sathya Baman Avatar asked May 17 '15 08:05

Sathya Baman


1 Answers

As I mentioned already, following examples in repository, Google/autoload.php should be included before using classes/instantiating objects. In your case it is APPPATH . 'third_party/Google/autoload.php' file.

like image 127
Tpojka Avatar answered Sep 27 '22 01:09

Tpojka