Closed maxencecalvez closed 9 years ago
I had to edit the gapi.class.php line 241 from " /**
@return Array of gapiReportEntry objects */
protected function reportObjectMapper($json_string) { $json = json_decode($json_string, true); $this->results = null; $results = array(); $report_aggregate_metrics = array(); //Load root parameters // Start with elements from the root level of the JSON that aren't themselves arrays. $report_root_parameters = array_filter($json, function($var){ return !is_array($var); }); "
to " protected function isArray($var) { return !is_array($var); } /**
@return Array of gapiReportEntry objects */
protected function reportObjectMapper($json_string) { $json = json_decode($json_string, true); $this->results = null; $results = array(); $report_aggregate_metrics = array(); //Load root parameters // Start with elements from the root level of the JSON that aren't themselves arrays. $report_root_parameters = array_filter($json, "isArray"); "
I am getting same error and unfortunately this didn't solved it for me. What was the issue you think it had. I am using xampp with php 5.6 on windows 8.1
Well, I should had been more specific. I did this correction because the declaration of a function wasn't accepted by my 5.2.9 version of PHP. I still have the invalid_grant error.
that error is gone when I enter the email provided in google developer console in service account. Can you try with that and respond.
But now I am getting permission error though i have added it in google analytics user as well
Actually it worked now. Use the service email address for authentication and add same email in google analytics user management with permissions. It worked for me after 10-15 mins of adding email in google analytics
Invalid_grant error is usually caused by using an invalid service account, for example one that doesn't end in '@developer.gserviceaccount.com' (for example if you used an @gmail.com account). Please confirm that your account is set up OK and has Analytics API access enabled.
In my case, the mail is correct as it works on an other server. Its format is "*****developer.gserviceaccount.com and the account has the credentials on Google Analytics.
I've created the services account and .p12 key. Analytics API is enabled in the console. Added the services account email with permission "Read & Analyze" in Google Analytics. Waited an hour and still having the 'GAPI: Failed to authenticate user'
Trust me I've followed this thread carefully... I don't know what to do now...
I use gapi to display analytics reports on websites. I have your solution working well on one server but on an other one, it returns this error : " 500 | Internal Server Error | Exception GAPI: Failed to authenticate user. Error: "{ "error": "invalid_grant", "error_description": "Bad Request" } gapi.class.php line 541 gapiOAuth2->fetchToken() line 50 " It's integrated in symfony 1.4 on a 5.2.9 PHP version The server is time synchronised (Windows 2008 R2 => w32tm resync) And since it's working on the other server, I guessed it wasn't a matter of token. Do you have any clue what I'm doing wrong ? Could it be the PHP version is incompatible ? Thanks