Search code examples
phplaravelgoogle-apigoogle-my-business-api

Class "Google_Service_MyBusiness" not found in Laravel


I use Google My Business API to fetch the account list, but it shows the following error.

"Class "Google_Service_MyBusiness" not found."

In my Laravel project, I am using Google Analytics, and its classes are working correctly. I installed the google/apiclient": "2.12" package. Do I need to install any other libraries to access my Google My Business account?

$mybusinessService = new \Google_Service_MyBusiness($client);
$accounts = $mybusinessService->accounts;
$accountsList = $accounts->listAccounts()->getAccounts();

Solution

  • First off, FYI: The GMB API will be deprecated as it is to be replaced by the new Business Profile APIs (https://developers.google.com/my-business/ref_overview).

    The new APIs are part of the Google PHP API Client Services.

    In order to list accounts via the Account Management API (google-api-php-client-services/src/MyBusinessAccountManagement/), I suggest you take a look at Accounts.php.