CodeIgniter Forums
[SOLVED] How can I call a Google Application using CI4 - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: [SOLVED] How can I call a Google Application using CI4 (/showthread.php?tid=79243)



[SOLVED] How can I call a Google Application using CI4 - John_Betong - 05-17-2021

I have developed a couple of PHP online websites using Google Books API and struggling to get the API to work with CI4.

With PHP I use Composer to download the API then the following couple of lines and it works a treat:

Code:
require_once '/var/www/ci2/vendor/autoload.php';

$tmpUrl = 'https://console.cloud.google.com/home/dashboard?project=PROJECT_NO_GOES_HERE;

$GOOGLE_API_PROJECT_ID = 'API-KEY-GOES-HERE';

 // CI4 ==> "Class "App\Controllers\Google_Client" not found"
 $client = new Google_Client();



RE: How can I call a Google Application using CI4 - InsiteFX - 05-17-2021

Did you add a use path\Google_Client ?

Also you may need a backslash \Google_Client();


RE: How can I call a Google Application using CI4 - John_Betong - 05-18-2021

@InsiteFX,
> Did you add a use path\Google_Client ?
Using require_once '/var/www/ci2/vendor/autoload.php'; worked.

I could not set namespace and/or use?

> Also you may need a backslash \Google_Client();
Many thanks the problem was the missing leading backslash.

I've experienced the same problem earlier (since using CI4 namespaces) and had forgotten Sad