• <tfoot id='kyyEC'></tfoot>

    <small id='kyyEC'></small><noframes id='kyyEC'>

    <legend id='kyyEC'><style id='kyyEC'><dir id='kyyEC'><q id='kyyEC'></q></dir></style></legend>

        • <bdo id='kyyEC'></bdo><ul id='kyyEC'></ul>
      1. <i id='kyyEC'><tr id='kyyEC'><dt id='kyyEC'><q id='kyyEC'><span id='kyyEC'><b id='kyyEC'><form id='kyyEC'><ins id='kyyEC'></ins><ul id='kyyEC'></ul><sub id='kyyEC'></sub></form><legend id='kyyEC'></legend><bdo id='kyyEC'><pre id='kyyEC'><center id='kyyEC'></center></pre></bdo></b><th id='kyyEC'></th></span></q></dt></tr></i><div id='kyyEC'><tfoot id='kyyEC'></tfoot><dl id='kyyEC'><fieldset id='kyyEC'></fieldset></dl></div>

        “权限不足"谷歌分析 API 服务帐号

        quot;Not sufficient permissionsquot; google analytics API service account(“权限不足谷歌分析 API 服务帐号)

            <tbody id='LUJtL'></tbody>
              <bdo id='LUJtL'></bdo><ul id='LUJtL'></ul>

                <small id='LUJtL'></small><noframes id='LUJtL'>

                <tfoot id='LUJtL'></tfoot>
                • <legend id='LUJtL'><style id='LUJtL'><dir id='LUJtL'><q id='LUJtL'></q></dir></style></legend>

                  <i id='LUJtL'><tr id='LUJtL'><dt id='LUJtL'><q id='LUJtL'><span id='LUJtL'><b id='LUJtL'><form id='LUJtL'><ins id='LUJtL'></ins><ul id='LUJtL'></ul><sub id='LUJtL'></sub></form><legend id='LUJtL'></legend><bdo id='LUJtL'><pre id='LUJtL'><center id='LUJtL'></center></pre></bdo></b><th id='LUJtL'></th></span></q></dt></tr></i><div id='LUJtL'><tfoot id='LUJtL'></tfoot><dl id='LUJtL'><fieldset id='LUJtL'></fieldset></dl></div>
                • 本文介绍了“权限不足"谷歌分析 API 服务帐号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在尝试通过服务帐户使用 Google Analytics API 获取数据.

                  我一直在 stackoverflow 上搜索如何执行此操作,并且一直在使用在几篇文章中找到的完全相同的代码,但在使其正常工作时遇到了问题.

                  来源:

                  I'm trying to fetch data with the Google Analytics API through service accounts.

                  I have been searching on stackoverflow how to do this and been using the exact same code found on several posts but getting problems to get it working.

                  Sources:

                  Service Applications and Google Analytics API V3: Server-to-server OAuth2 authentication?

                  Service Applications and Google Analytics API V3: Error 101 (net::ERR_CONNECTION_RESET)

                  http://code.google.com/p/google-api-php-client/source/browse/trunk/examples/prediction/serviceAccount.php

                  This is what i got:

                  require_once('googleAPIGoogle_Client.php');
                  require_once('googleAPI/contrib/Google_AnalyticsService.php');
                  
                  const CLIENT_ID = 'xxxxxxxx001.apps.googleusercontent.com';
                  const SERVICE_ACCOUNT_NAME = 'xxxxxx001@developer.gserviceaccount.com';
                  
                  
                  $keyfile = $_SERVER['DOCUMENT_ROOT']."/xxxxxxx284-privatekey.p12";
                  
                  
                  $client = new Google_Client();
                  $client->setAccessType('offline');
                  $client->setApplicationName("cc insights");
                  
                  
                  $key = file_get_contents($keyfile);
                  $client->setClientId(CLIENT_ID);
                  
                  $client->setAssertionCredentials(new Google_AssertionCredentials(
                      SERVICE_ACCOUNT_NAME,
                      array('https://www.googleapis.com/auth/analytics.readonly'),
                      $key)
                  );
                  
                  
                  $service = new Google_AnalyticsService($client);
                  
                  $data = $service->data_ga->get("ga:xxxx7777", "2012-01-01", "2013-01-25", "ga:pageviews");
                  var_dump($data);
                  

                  when executing i got the following error:

                  Fatal error: Uncaught exception 'Google_ServiceException' with message 'Error calling GET https://www.googleapis.com/analytics/v3/data/ga?ids=ga%3Axxxx7777&start-date=2012-01-01&end-date=2013-01-25&metrics=ga%3Apageviews: (403) User does not have sufficient permissions for this profile.' in /Applications/XAMPP/xamppfiles/htdocs/insights/application/libraries/googleAPI/io/Google_REST.php:66 Stack trace: #0 /Applications/XAMPP/xamppfiles/htdocs/insights/application/libraries/googleAPI/io/Google_REST.php(36): Google_REST::decodeHttpResponse(Object(Google_HttpRequest)) #1 /Applications/XAMPP/xamppfiles/htdocs/insights/application/libraries/googleAPI/service/Google_ServiceResource.php(178): Google_REST::execute(Object(Google_HttpRequest)) #2 /Applications/XAMPP/xamppfiles/htdocs/insights/application/libraries/googleAPI/contrib/Google_AnalyticsService.php(383): Google_ServiceResource->__call('get', Array) #3 /Applications/XAMPP/xamppfiles/htdocs/insights/application/libraries/Google.php(46): Google_DataGaServiceResource->get('g in /Applications/XAMPP/xamppfiles/htdocs/insights/application/libraries/googleAPI/io/Google_REST.php on line 66

                  Because i'm using the exact same code as working examples, i think it might be a problem with the API or service account settings?

                  This is the user that i added to the analytics account :

                  and this is api access accounts:

                  Does anybody know what i'm doing wrong?

                  解决方案

                  I was getting exactly the same error and this solved it for me:

                  I was using the account ID instead of the View ID. Switching to the View ID fixed it - it’s always the "View ID" and not the account or property ID (which looks like "UA-xxx"). The View ID is for a specific web property and can be found in the Admin->View (3rd column)->View Settings. It’s an integer with no dashes.

                  https://stackoverflow.com/a/15789266/1391229

                  这篇关于“权限不足"谷歌分析 API 服务帐号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  PHP Upload File Validation(PHP 上传文件验证)
                  PHP Error - Uploading a file(PHP 错误 - 上传文件)
                  How can I write tests for file upload in PHP?(如何在 PHP 中编写文件上传测试?)
                  php resizing image on upload rotates the image when i don#39;t want it to(php在上传时调整图像大小会在我不想要它时旋转图像)
                  How to send additional data using PLupload?(如何使用 PLupload 发送附加数据?)
                  change button text in js/ajax after mp4 =gt;mp3 conversion in php(在 php 中的 mp4 =gt;mp3 转换后更改 js/ajax 中的按钮文本)
                • <legend id='h9rKL'><style id='h9rKL'><dir id='h9rKL'><q id='h9rKL'></q></dir></style></legend><tfoot id='h9rKL'></tfoot>

                        <tbody id='h9rKL'></tbody>
                        • <bdo id='h9rKL'></bdo><ul id='h9rKL'></ul>
                          <i id='h9rKL'><tr id='h9rKL'><dt id='h9rKL'><q id='h9rKL'><span id='h9rKL'><b id='h9rKL'><form id='h9rKL'><ins id='h9rKL'></ins><ul id='h9rKL'></ul><sub id='h9rKL'></sub></form><legend id='h9rKL'></legend><bdo id='h9rKL'><pre id='h9rKL'><center id='h9rKL'></center></pre></bdo></b><th id='h9rKL'></th></span></q></dt></tr></i><div id='h9rKL'><tfoot id='h9rKL'></tfoot><dl id='h9rKL'><fieldset id='h9rKL'></fieldset></dl></div>

                            <small id='h9rKL'></small><noframes id='h9rKL'>