Welcome Guest, Not a member yet? Register   Sign In
Google API php client
#1

(This post was last modified: 05-01-2020, 11:28 AM by php_rocs.)

hi, I am trying to use the google client api. Following the instructions of developers.google.com/sheets/api/quickstart/php, I can't get to instantiate the client object.

I put this code in my controller:
PHP Code:
<?php namespace App\Controllers;

require_once   (__DIR__ './../ThirdParty/googleApi/vendor/autoload.php');

class 
GoogleSheetData extends BaseController
{
    public function index()
    {
        putenv('GOOGLE_APPLICATION_CREDENTIALS='.(__DIR__ './../ThirdParty/xxxxxx.json'));
        $client = new Google_Client();
.
.


but I get the error:
Class 'App\Controllers\Google_Client' not found

I appreciate any help, thanks
code live
Reply
#2

You installed it the manual way correct?

Try with:
new \Google_Client();

PS. Moved your thread to General help as it's more of a PHP7 and namespacing problem than CI4.
Reply
#3

It has worked, I have already understood, thank you.
I have another question, yesterday I tried to install with composer. Install CI 4 first and then API Google Client. But I notice that a vendor folder has been created with a copy of the CI4 structure inside.
This is normal?
code live
Reply
#4

Great that it worked out for you!

It's the correct structure for the Appstarter.

You can read more in this thread:
https://forum.codeigniter.com/thread-76237.html
Reply
#5

I think I just understood how composer works. It is amazing, i think that is the best option for future updates.

Thank you so much!!
code live
Reply




Theme © iAndrew 2016 - Forum software by © MyBB