GAPI:无法请求报告数据,并且未提供更多信息


GAPI: Failed to request report data and provides no further information

我们使用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,这是好的(Google Analytics URL中p后面的8位数字)。

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

非常感谢您的帮助!

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

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