Adding google api client to codeigniter

13,093

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.

Share:
13,093
Sathya Baman
Author by

Sathya Baman

A software engineer with experience in programming software across various platforms. I am a specialist in Mobile technologies, I take pride in coding to consistently high standards. Website sathyabaman.com Git Hub Sathya-Baman Linkedin sathyabaman Play Store sathyabaman Love to code && I live to code.

Updated on June 09, 2022

Comments

  • Sathya Baman
    Sathya Baman almost 2 years

    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.