Loading google api client library in codeiniter

≯℡__Kan透↙ 提交于 2019-12-10 10:46:04

问题


first I copied the Google folder to application/third_party in codeigniter framework.

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 have 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 I'm doing wrong ??


回答1:


I am assuming that you have autoload.php in application/third_party directory, and rest of the source in application/third_party/Google directory.

in the application/libraries/google.php remove this line.

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

now the code google.php will 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 that error.




回答2:


Please try this way load your libraries :include_once APPPATH . "libraries/third_party/Google/Client.php";



来源:https://stackoverflow.com/questions/28134203/loading-google-api-client-library-in-codeiniter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!