分析报告 API V4 api 问题

Analytics Reporting API V4 api issue

我正在尝试实施 Analytics Reporting API V4。 使用此示例 link

Fatal error: Uncaught exception 'Google_Service_Exception' with message ' in

Google_Service_Exception: { "error": "invalid_scope", "error_description": "Empty or missing scope not allowed." }

请帮我解决这个错误。

谢谢

发现得很好。我认为该教程中存在错误。

$client->setAuthConfig($KEY_FILE_LOCATION);
$client->setScopes(['https://www.googleapis.com/auth/analytics.readonly']);
$analytics = new Google_Service_AnalyticsReporting($client);

尝试在您的代码中添加上面的中间行。您需要为其设置一个范围才能工作。

让我知道它是否有效,我会向开发团队发送电子邮件并更正教程。