I am using google API php client and getting below error. This code is working fine before a week. Current its not working and passing error. may be some deprecated by google after that its not working. Please help me out as soon as possible because its affect on live product and can't able to show review.
$http = new GuzzleHttp\Client([
'verify' => false
]);
$client = new Google_Client();
$client->setHttpClient($http);
$client->setApplicationName('Magic Minds WEB');
$client->setAuthConfigFile(CLIENT_SECRET_PATH);
$client->setRedirectUri(redirectUri);
$client->setScopes("https://www.googleapis.com/auth/business.manage");
$client->setAccessType("offline");
$client->setApprovalPrompt("force");
$mybusinessService = new Google_Service_MyBusiness($client);
$credentialsPath = tokenJson;
// Load previously authorized credentials from a file.
$accessToken = (array)json_decode(file_get_contents($credentialsPath));
$client->setAccessToken($accessToken);
// Refresh the token if it's expired.
if ($client->isAccessTokenExpired()) {
$client->refreshToken($client->getRefreshToken());
file_put_contents($credentialsPath, json_encode($client->getAccessToken()));
}
// For testing purposes, selects the very first account in the accounts array
$accounts = $mybusinessService->accounts;
// echo "<pre>";
//print_r($accounts);
$accountsList = $accounts->listAccounts()->getAccounts();
print_r($accountsList);
$account = $accountsList[2];
// For testing purposes, selects the very first location in the locations array
$locations = $mybusinessService->accounts_locations;
$locationsList = $locations->listAccountsLocations($account->name)->getLocations();
$location = $locationsList[0];
// Lists all reviews for the specified location
$reviews = $mybusinessService->accounts_locations_reviews;
$listReviewsResponse = $reviews->listAccountsLocationsReviews($location->name);
$reviewsList = $listReviewsResponse->getReviews();
Getting below error
Fatal error: Uncaught Google\Service\Exception: { "error": { "code": 400, "message": "Request contains an invalid argument.", "errors": [ { "message": "Request contains an invalid argument.", "domain": "global", "reason": "badRequest" } ], "status": "INVALID_ARGUMENT", "details": [ { "@type": "type.googleapis.com/google.mybusiness.v4.ValidationError", "errorDetails": [ { "message": "This API will soon be deprecated. Please migrate all the usages to My Business Account Management API - https://developers.google.com/my-business/reference/accountmanagement/rest" } ] } ] } } in /var/www/html/magicmind/magicmindsweb/backend/vendor/google/apiclient/src/Http/REST.php:128 Stack trace: #0 /var/www/html/magicmind/magicmindsweb/backend/vendor/google/apiclient/src/Http/REST.php(103): Google\Http\REST::decodeHttpResponse() #1 [internal function]:
efforts will be appreciated. Thanks in advance