andeedee / gapi-google-analytics-php-interface

Automatically exported from code.google.com/p/gapi-google-analytics-php-interface
0 stars 0 forks source link

Failed to request report data and provides no further information #107

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
We're using the **PHP GAPI** 
([https://code.google.com/p/gapi-google-analytics-php-interface/) to retrieve 
data and to show graphs in admin panel of our websites.

We know this library hasn’t been updated since 2009, but it was working fine 
for us for a long time until some months ago...

Bellow is the error we got :

    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/lacentrale/gapi.class.php on line 218

Here is the code for *include.dashboard.analytics.visits.php* — lines 35 to 
39 (error on line 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);
    }

And here is the code for *gapi.class.php* — lines 212 to 219 (error on line 
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']) . '"');
    }

We don’t fully understand these errors which are not so clear, and as nothing 
changed in these files...

As we seen on other StackOverflow tickets and other forums, we've already 
checked our profile ID which is the good one (8 digits after the p in the 
Google Analytics URL).

We would like to not move to another PHP API for GA (if any other available? 
what would be the best solution as of today?) because it would required a lot a 
work to implement again the admin panel we've made ...

Many thanks for your help!

Original issue reported on code.google.com by rom...@everythingisfun.eu on 26 Dec 2014 at 9:25

GoogleCodeExporter commented 9 years ago
Problem solved : we had made modifications into the *gapi.class.php* file since 
a long time for a project which required special securised specifications for 
server connection and we were still using this file modified in other projects 
which do not required this modifications...

So we downloaded a clean copy of GAPI and replaced with the initial file to 
solve the problem ;-)

Original comment by rom...@everythingisfun.eu on 26 Dec 2014 at 10:23