I am quite new to the use of Google APIs in PHP, and I am currently trying to get a list of the last Google Reviews submitted for a business.
At first, I used Google Places API to get the job done, which was simple to use (no need for OAuth connection process, a simple HTTP request was enough) but I've learned that this method only returns the last 5 reviews of a business, and I need to get a list of all the reviews.
That's why I red that I needed to go with Google My Business API if I wanted get the full list of reviews for a business. But it's been days that I am trying to get this API to work, and I still haven't managed to even connect my app to the API using OAuth protocol.
Though I've started from a pre-made Github example, I'm still getting this error message when trying to acess the API : PHP error message that I'm currently getting
I don't understand why, as I really did everything that is mentionned in the documentation.
If anybody can have a little look at my code and help me knowing what is wrong with it, that'd be huge help really ! Any piece of information would be much appreciated.
Here is my code :
$credentials = get_stylesheet_directory() . '/allia-google-api/google-my-business-secrets.json';
$client = new Google\Client();
$client->setAuthConfig($credentials);
$client->addScope("https://www.googleapis.com/auth/business.manage");
$redirect_uri = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
$client->setRedirectUri($redirect_uri);
$my_business_account = new Google_Service_MyBusinessAccountManagement($client);
$list_accounts_response = $my_business_account->accounts->listAccounts();
var_dump($list_accounts_response);