0

我需要为一家营销公司编写一个网络应用程序,该公司需要连接到他们的客户网站以访问谷歌分析数据并将其存储在他们的数据库中。我按照 Google 在以下位置提供的示例: https ://developers.google.com/analytics/solutions/articles/hello-analytics-api 我在 Google API 控制台创建了以下客户端 ID

Client ID:      915242733409.apps.googleusercontent.com
Email address:  915242733409@developer.gserviceaccount.com
Client secret:  xxx
Redirect URIs:  http://thefridgedoors.net/google-analytics/google-api-php-client/examples/analytics/simple.php
JavaScript origins: https://www.thefridgedoors.net

我的应用程序的身份验证如下所示:

/* Start a session to persist credentials */
session_start();

/* Create and configure a new client object */
$client = new Google_Client();
$client->setApplicationName("Google+ PHP Starter Application");
// Visit https://code.google.com/apis/console to generate your
// oauth2_client_id, oauth2_client_secret, and to register your oauth2_redirect_uri.
$client->setClientId('915242733409.apps.googleusercontent.com');
$client->setClientSecret('…');
$client->setRedirectUri('http://thefridgedoors.net/google-analytics/example1.php');
$client->setDeveloperKey('…');
$client->setScopes(array('https://www.googleapis.com/auth/analytics.readonly'));

但是我收到以下错误:出现一般错误:

Error calling GET https://www.googleapis.com/analytics/v3/management/accounts?key=AIzaSyALRCwV32b8fAtcvFuaDVwNUxrYrtg51tI: (403) Access Not Configured

有什么可能出错的提示吗?

4

1 回答 1

2

您需要在Google APIs Console中为您的项目启用 Analytics API 。打开您的项目,选择“服务”选项卡,然后单击Analytics API 的“状态”列下的开关。

PS您可能希望避免发布您的客户机密。

于 2013-07-19T07:07:26.537 回答