我们正在使用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(如果有其他可用的?到目前为止最好的解决方案是什么?),因为再次实现我们制作的管理面板需要做很多工作......
非常感谢您的帮助!