首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >YouTube分析API PHP: usageLimits accessNotConfigured

YouTube分析API PHP: usageLimits accessNotConfigured
EN

Stack Overflow用户
提问于 2014-12-23 15:08:23
回答 1查看 403关注 0票数 2

我正在使用通过wanze。我能够设置身份验证(仅使用web )和一切,并将令牌存储在会话中。在另一页上,我使用此代码查找用户登录的所有帐户。

代码语言:javascript
运行
复制
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); 

我回来了:

代码语言:javascript
运行
复制
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:

提前谢谢你,

,如果您需要更多的细节,请告诉我!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-12-26 23:22:04

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

您需要做的是在开发人员控制台中添加到API列表"Analytics“中。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/27623007

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档