XF 2.2 Connecting to G search console API failure

Anatoliy

Well-known member
So I'm a noob in xF development and know nothing about GSC API, but that didn't stop me. )))

I uploaded GSC API package into /src/vendors/ and created an addon with admin route. When I add require_once '/src/vendor/google-api-php-client--PHP8.0/vendor/autoload.php'; to my controller's action it throws an error
Code:
ErrorException: [E_WARNING] require_once(/src/vendor/google-api-php-client--PHP8.0/vendor/autoload.php): Failed to open stream: No such file or directory in src\addons\AV\LinkedThreads\Pub\Controller\MyController.php at line 57
XF::handlePhpError() in src\addons\AV\LinkedThreads\Pub\Controller\MyController.php at line 57
require_once() in src\addons\AV\LinkedThreads\Pub\Controller\MyController.php at line 57
AV\LinkedThreads\Pub\Controller\MyController->actionKeywords() in src\XF\Mvc\Dispatcher.php at line 352
XF\Mvc\Dispatcher->dispatchClass() in src\XF\Mvc\Dispatcher.php at line 259
XF\Mvc\Dispatcher->dispatchFromMatch() in src\XF\Mvc\Dispatcher.php at line 115
XF\Mvc\Dispatcher->dispatchLoop() in src\XF\Mvc\Dispatcher.php at line 57
XF\Mvc\Dispatcher->run() in src\XF\App.php at line 2352
XF\App->run() in src\XF.php at line 524
XF::runApp() in admin.php at line 13

but the file is there and the path is correct 🤷‍♂️
It stopped throwing an error after I removed the first slash
require_once 'src/vendor/google-api-php-client--PHP8.0/vendor/autoload.php';
but when I added the rest of the example code
Code:
            $client = new Google\Client();
            $client->setApplicationName("Client_Library_Examples");
            $client->setDeveloperKey("xxxxxx");

            $service = new Google\Service\Books($client);
            $query = 'Henry David Thoreau';
            $optParams = [
            'filter' => 'free-ebooks',
            ];
            $results = $service->volumes->listVolumes($query, $optParams);
it shows an error
Code:
Error: Class "AV\LinkedThreads\Pub\Controller\Google\Client" not found in src\addons\AV\LinkedThreads\Pub\Controller\MyController.php at line 59
AV\LinkedThreads\Pub\Controller\MyController->actionKeywords() in src\XF\Mvc\Dispatcher.php at line 352
XF\Mvc\Dispatcher->dispatchClass() in src\XF\Mvc\Dispatcher.php at line 259
XF\Mvc\Dispatcher->dispatchFromMatch() in src\XF\Mvc\Dispatcher.php at line 115
XF\Mvc\Dispatcher->dispatchLoop() in src\XF\Mvc\Dispatcher.php at line 57
XF\Mvc\Dispatcher->run() in src\XF\App.php at line 2352
XF\App->run() in src\XF.php at line 524
XF::runApp() in admin.php at line 13
and Viual Studio Code underlines with red Google\Client and Google\Service\Books.

Please advise what I'm doing wrong and how to fix it.
 
Top