【问题标题】:GAPI: Failed to request report data and provides no further informationGAPI:请求报告数据失败且未提供更多信息
【发布时间】:2015-02-21 19:12:57
【问题描述】:

我们正在使用 PHP GAPI ([https://code.google.com/p/gapi-google-analytics-php-interface/) 来检索数据并在我们网站的管理面板中显示图表。

我们知道这个库自 2009 年以来就没有更新过,但它在很长一段时间内对我们都很好,直到几个月前...

下面是我们得到的错误:

Fatal error:
Uncaught exception 'Exception' with message 'GAPI: Failed to request report data.
Error: "Request failed, fopen provides no further information"' in /www/clientname/site/lacentrale/gapi.class.php:218

Stack trace:
#0 /www/clientname/site/cms/include.dashboard.analytics.visits.php(37): gapi->requestReportData('95220065', Array, Array, Array, NULL, '2014-11-23', '2014-12-22', 1, 30)
...
#6 {main} thrown in /www/clientname/site/cms/gapi.class.php on line 218

这是 include.dashboard.analytics.visits.php 的代码——第 35 到 39 行(第 37 行出错):

if ( ! $ga = $myCache->getCache() ){
    $ga = new gapi(ga_email,ga_password);
    $ga->requestReportData(ga_profile_id,array($dimension),array('visits','pageviews','timeOnSite','avgTimeOnSite','pageviewsPerVisit'),array($dimension),null,$begin,$end,1,$max);
    $myCache->saveCache($ga);
}

这是 gapi.class.php 的代码——第 212 到 219 行(第 218 行错误):

if(substr($response['code'],0,1) == '2')
{
  return $this->reportObjectMapper($response['body']);
}
else 
{
  throw new Exception('GAPI: Failed to request report data. Error: "' . strip_tags($response['body']) . '"');
}

我们不完全理解这些不太清楚的错误,因为这些文件中没有任何变化......

正如我们在其他 StackOverflow 票证和其他论坛上看到的那样,我们已经检查了我们的个人资料 ID,这是一个不错的 ID(Google Analytics URL 中 p 后面的 8 位数字)。

我们不想迁移到另一个用于 GA 的 PHP API(如果有其他可用的?目前最好的解决方案是什么?)因为再次实现我们制作的管理面板需要大量工作...

非常感谢您的帮助!

【问题讨论】:

    标签: php google-analytics google-api-js-client


    【解决方案1】:

    问题已解决:我们已经对 gapi.class.php 文件进行了很长时间的修改,因为该项目需要特殊的安全规范来连接服务器,而我们仍在使用在其他地方修改过的这个文件不需要此修改的项目...

    所以我们下载了 GAPI 的干净副本并替换为初始文件以解决问题 ;-)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-10-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-04
      • 1970-01-01
      相关资源
      最近更新 更多