• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Load google-api-php-client as package

#1
[eluser]redcloud80[/eluser]
Hi! I'm trying to load google-api-php-client as a package into one of my controllers but there's something wrong that I'm unable to fix.
Once downloaded this https://github.com/google/google-api-php-client
I've copied the src/Google directory into CI third_party.
Then inside my controller I try to load the Client.php file (which contains a Google_Client class) using this code

Code:
public function index()
{
$this->load->add_package_path(APPPATH . 'third_party/Google');
$this->load->library('client');
}

that returns this error "Unable to load the requested class: client"

What's the missing block?

#2
[eluser]Karman de Lange[/eluser]
Probably not the best way of doing it, but it works (well for me)

Create new file under application/library called google.php

Code:
<?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 to use:

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

#3
[eluser]redcloud80[/eluser]
Thanks Karman! It works for me too. So there's no way to load this library directly as a package?

#4
[eluser]Karman de Lange[/eluser]
Probably is, hopefully one of the clever people might chirp in ;-)

L:

#5
[eluser]redcloud80[/eluser]
[quote author="Karman de Lange" date="1387808901"]Probably is, hopefully one of the clever people might chirp in ;-)

L:[/quote]
Do you have any example about how to create an event on a given calendar? I'm using Google APIs Client Library for PHP 1.0 which has no useful examples :\

#6
[eluser]Karman de Lange[/eluser]
[quote author="redcloud80" date="1387811563"][quote author="Karman de Lange" date="1387808901"]Probably is, hopefully one of the clever people might chirp in ;-)

L:[/quote]
Do you have any example about how to create an event on a given calendar? I'm using Google APIs Client Library for PHP 1.0 which has no useful examples :\[/quote]

Actually never used the library, but have look for you tomorrow ..

L:

#7
[eluser]Tpojka[/eluser]
I think it is up to organiying files / folders.
Reading docs, I think Client.php should be in folder
Code:
application/third_party/Google/library
Or try some combination regarding this topic

I am bit confused why don't file name and class name are not the same.
But if Karman's solution works it is not main problem here.

But there is risk of possible affection to other files so it should be organized accordingly eventually errors. Smile


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.