【问题标题】:YouTube Analytics API PHP: usageLimits accessNotConfiguredYouTube 分析 API PHP:usageLimits accessNotConfigured
【发布时间】:2014-12-23 15:08:23
【问题描述】:

我正在使用 wanze 的 [Google Analytics API PHP]。我能够设置身份验证(仅使用 Web 身份验证)和所有内容,并将令牌存储在会话中。在另一个页面上,我使用此代码查找用户登录时使用的所有帐户。

session_start();
include('GoogleAnalyticsAPI.class.php');

$ga = new GoogleAnalyticsAPI(); 
$ga->auth->setClientId('replaces'); // From the APIs console
$ga->auth->setClientSecret('replaces'); // From the APIs console
$ga->auth->setRedirectUri('replaced'); // Url to your app, must match one in the APIs console

// Get the Auth-Url
$url = $ga->auth->buildAuthUrl();

// Set the accessToken and Account-Id
$ga->setAccessToken($_SESSION['accessToken']);
$ga->setAccountId('ga:xxxxxxx');

// Load profiles
$profiles = $ga->getProfiles();
print_r($profiles);
$accounts = array();
foreach ($profiles['items'] as $item) {
    $id = "ga:{$item['id']}";
    $name = $item['name'];
    $accounts[$id] = $name;
}
// Print out the Accounts with Id => Name. Save the Id (array-key) of the account you want to query data. 
// See next chapter how to set the account-id.
print_r($accounts); 

我这回了:

Array
(
    [http_code] => 403
    [error] => Array
        (
            [errors] => Array
                (
                    [0] => Array
                        (
                            [domain] => usageLimits
                            [reason] => accessNotConfigured
                            [message] => Access Not Configured. The API is not enabled for your project, or there is a per-IP or per-Referer restriction configured on your API key and the request does not match these restrictions. Please use the Google Developers Console to update your configuration.
                            [extendedHelp] => https://console.developers.google.com
                        )

                )

            [code] => 403
            [message] => Access Not Configured. The API is not enabled for your project, or there is a per-IP or per-Referer restriction configured on your API key and the request does not match these restrictions. Please use the Google Developers Console to update your configuration.
        )

)
<br />
<b>Warning</b>:  Invalid argument supplied for foreach() in <b>/home3/chalzzy/public_html/dashboard/dashboard.php</b> on line <b>21</b><br />
Array
(
)

我在很多地方看到我需要在控制台的“推荐”部分中删除或设置所有引用,但我似乎无法在新控制台或旧控制台中找到这些。如果它在那里,我找不到它,你能给我一个网址或截图吗?

另外,这些是我为这个项目安装的所有 API:

提前致谢,

另外,如果您需要更多详细信息,请告诉我!

【问题讨论】:

    标签: php youtube youtube-api youtube-analytics


    【解决方案1】:

    嘿(对不起,这是一个非常愚蠢的问题),

    您需要做的是添加到Developers Console 中的 API 列表“Analytics API”。

    【讨论】:

      猜你喜欢
      • 2013-08-14
      • 2020-01-07
      • 2013-06-28
      • 2014-04-30
      • 2015-01-01
      • 2014-08-18
      • 2019-08-31
      • 1970-01-01
      • 2023-04-08
      相关资源
      最近更新 更多