如何正确设置Google Analytics(分析)Report API V4?

时间:2018-06-22 09:44:03

标签: php-7 google-analytics-v4

到目前为止我所做的事情:

  1. 我正在尝试的是:Setup simple example of google analytics
  2. 我已经启用了Google Analytics API
  3. 我已经创建了一个Service account keys。我的键名:My Project-fc5b5fd6b551.json
  4. 我已经启用了我的演示 Google Analytics(分析)帐户,请参考: https://support.google.com/analytics/answer/6367342#access
  5. 我已经composer require google/apiclient:^2.0
  6. 我已经有一个view_id,它是模拟帐户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

0 个答案:

没有答案