到目前为止我所做的事情:
Setup simple example of google analytics
Google Analytics API
。Service account keys
。我的键名:My
Project-fc5b5fd6b551.json
composer require google/apiclient:^2.0
Raw Data View
但是我莫名其妙地出现了这个错误:
Fatal error: Uncaught Google_Service_Exception: { "error": { "code": 403, "message": "User does not have any Google Analytics account.", "errors": [ { "message": "User does not have any Google Analytics account.", "domain": "global", "reason": "forbidden" } ], "status": "PERMISSION_DENIED" } } in /Applications/MAMP/htdocs/native_analytics/vendor/google/apiclient/src/Google/Http/REST.php:118 Stack trace: #0 /Applications/MAMP/htdocs/native_analytics/vendor/google/apiclient/src/Google/Http/REST.php(94): Google_Http_REST::decodeHttpResponse(Object(GuzzleHttp\Psr7\Response), Object(GuzzleHttp\Psr7\Request), 'Google_Service_...') #1 /Applications/MAMP/htdocs/native_analytics/vendor/google/apiclient/src/Google/Task/Runner.php(176): Google_Http_REST::doExecute(Object(GuzzleHttp\Client), Object(GuzzleHttp\Psr7\Request), 'Google_Service_...') #2 /Applications/MAMP/htdocs/native_analytics/vendor/google/apiclient/src/Google/Http/REST.php(58): Google_Task_Runner->run() #3 / in /Applications/MAMP/htdocs/native_analytics/vendor/google/apiclient/src/Google/Http/REST.php on line 118
我确实遵循了一切。我不为什么会遇到此错误。我认为一种理论是无效的服务帐户密钥或错误的生成服务帐户密钥的方式,其二,我认为模拟帐户无效。
我正在使用 Hello Analytics Reporting API v4;服务帐户的PHP快速入门
参考:https://developers.google.com/analytics/devguides/reporting/core/v4/quickstart/service-php#1_enable_the_api