codeigniter with google-api-php-client not working/loading

1,472 views
Skip to first unread message

Andrew Hackley

unread,
Oct 4, 2013, 4:51:43 PM10/4/13
to google-api...@googlegroups.com
I recently started using the google-api-php-client and have gotten it to work no problem.  When I was satisfied with the basic functionality, I tried merging it into my codeigniter based website and so far haven't had any luck.  Everything works the same until I try to load the google-api-php-client from the codeigniter controller.  I have put these api files in the application/libraries folder within the codeigniter folder organization. here's the code in the top of my controller:

<?
class gcalendar extends Controller{
   
    function __construct() {
        parent::Controller();
        $this->load->model('user_model');
        $this->load->helper('url');
        $this->load->model('permissions_model');
       
        //import the google libraries
        echo "gcal constructor: line ".__LINE__."<br>";                                               //line 10
        $this->load->library('googleAPI/Google_Client');                                         //line 11
        $this->load->library('googleAPI/contrib/Google_CalendarService.php');         //line 12
        echo "gcal constructor: line ".__LINE__."<br>";                                               //line 13
    }

This is the result in a web browser:

gcal constructor: line 10
google client End Of File reached: line 473
google calendar client End Of File reached: line 1972

As you can tell, I've put an echo statement at the end of both of the google calendar api library files for debugging purposes.  So, my question is how can codeigniter get to the last line of the library loaded in line 12, but not get to line 13?

Thanks!

Andrew Hackley

unread,
Oct 5, 2013, 2:57:52 PM10/5/13
to google-api...@googlegroups.com
It turns out that CodeIgniter libraries need the class name to be the same as the imported library's file name.  So, I renamed Google_CalendarService.php to Google_AclServiceResource.php and it loaded no problem!  Now I just have to figure out how to make the google-api-php-client compatible with URL re-writing (apache rewrite_module)...

Andrew Hackley

unread,
Oct 5, 2013, 3:39:16 PM10/5/13
to google-api...@googlegroups.com
In addition, Google API uses OAuth which requires processing of $_GET data.  To make CodeIgniter able to process $_GET data, make a simple change in our config.php file as seen here:
Reply all
Reply to author
Forward
0 new messages