Download google api client library to the encoder

I first copied the Google folder to application / third_party as part of codeigniter.

and then google.php inside the application / libraries

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

and then I created a controller named googleClass.php

<?php
class GoogleClass extends CI_Controller {
    function __construct($params = array()) {
    parent::__construct();
}
public function index(){

    $this->load->library('google');
    echo $this->google->getLibraryVersion();
   }
}

But I get the following error ...

Fatal error: require_once(): Failed opening required '' (include_path='application/third_party/;.;C:\xampp\php\pear') in C:\xampp\htdocs\csvinsert\application\third_party\Google\Client.php on line 18

what am I doing wrong?

+2
source share
2 answers

I assume that you have autoload.phpin the directory application/third_partyand the remainder of the source in the directory application/third_party/Google.

in application/libraries/google.phpdelete this line.

set_include_path(APPPATH . 'third_party/' . PATH_SEPARATOR . get_include_path());

now the code google.phpwill be

<?php
if (!defined('BASEPATH')) exit('No direct script access allowed');

require_once APPPATH . 'third_party/Google/Client.php';

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

This will get rid of this error.

0
source

Try it so download the libraries: include_once APPPATH . "libraries/third_party/Google/Client.php";

0
source

All Articles