我有这个代码希望获取 google mybusiness revies:
putenv('GOOGLE_APPLICATION_CREDENTIALS=' . realpath($_SERVER["DOCUMENT_ROOT"]) . '/google-api/account-service-mybusiness.json');
$client = new Google_Client();
$client->useApplicationDefaultCredentials();
$client->setScopes("https://www.googleapis.com/auth/plus.business.manage");
$client->setIncludeGrantedScopes(true);
$user_to_impersonate = "xxxxxx@gmail.com";
$client->setSubject($user_to_impersonate);
$client->authorize();
$locationName = "accounts/xxxxxxxxxx/locations/xxxxxxxxxx";
$myBusinessService = new Google_Service_Mybusiness($client);
$reviews = $myBusinessService->accounts_locations_reviews;
但是当我尝试 fecth 评论时,我遇到了这个致命错误:
致命错误:未捕获的 Google_Service_Exception:{“error”:“unauthorized_client”,“error_description”:“客户端未经授权无法使用此方法检索访问令牌。” } 在 /web/htdocs/www.locandadalmoccia.it/home/google-api/vendor/google/apiclient/src/Google/Http/REST.php:118 堆栈跟踪:#0 /web/htdocs/www.locandadalmoccia。它/home/google-api/vendor/google/apiclient/src/Google/Http/REST.php(94): Google_Http_REST::decodeHttpResponse(Object(GuzzleHttp\Psr7\Response), Object(GuzzleHttp\Psr7\Request), 'Google_Service_...') #1 /web/htdocs/www.locandadalmoccia.it/home/google-api/vendor/google/apiclient/src/Google/Task/Runner.php(176): Google_Http_REST::doExecute(对象(GuzzleHttp\Client),对象(GuzzleHttp\Psr7\Request),'Google_Service_...')#2 /web/htdocs/www.
请问somneone可以帮我解决吗?