Reputation: 91
I am following with the article below, https://developers.google.com/analytics/devguides/reporting/core/v3/quickstart/web-php
But in the end, when I try with the sample code (HelloAnalytics.php), it will shows the error in command line as follows and cant get the data;
PHP Warning: count(): Parameter must be an array or an object that implements Countable in C:\xampp\htdocs\vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php on line 67
Warning: count(): Parameter must be an array or an object that implements Countable in C:\xampp\htdocs\vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php on line 67 PHP Warning: count(): Parameter must be an array or an object that implements Countable in C:\xampp\htdocs\vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php on line 67
Warning: count(): Parameter must be an array or an object that implements Countable in C:\xampp\htdocs\vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php on line 67 PHP Fatal error: Uncaught Google_Service_Exception: {"error":{"errors":[{"domain":"usageLimits","reason":"accessNotConfigured","message":"Project 687417168367 is not found and cannot be used for API calls. If it is recently created, enable Google Analytics API by visiting https://console.developers.google.com/apis/api/analytics.googleapis.com/overview?project=687417168367 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.","extendedHelp":"https://console.developers.google.com/apis/api/analytics.googleapis.com/overview?project=687417168367"}],"code":403,"message":"Project 687417168367 is not found and cannot be used for API calls. If it is recently created, enable Google Analytics API by visiting https://console.developers.google.com/apis/api/analytics.googleapis.com/overview?project=687417168367 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry."}} in C:\xampp\htdocs\vendor\google\apiclient\s in C:\xampp\htdocs\vendor\google\apiclient\src\Google\Http\REST.php on line 118
Fatal error: Uncaught Google_Service_Exception: {"error":{"errors":[{"domain":"usageLimits","reason":"accessNotConfigured","message":"Project 687417168367 is not found and cannot be used for API calls. If it is recently created, enable Google Analytics API by visiting https://console.developers.google.com/apis/api/analytics.googleapis.com/overview?project=687417168367 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.","extendedHelp":"https://console.developers.google.com/apis/api/analytics.googleapis.com/overview?project=687417168367"}],"code":403,"message":"Project 687417168367 is not found and cannot be used for API calls. If it is recently created, enable Google Analytics API by visiting https://console.developers.google.com/apis/api/analytics.googleapis.com/overview?project=687417168367 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry."}} in C:\xampp\htdocs\vendor\google\apiclient\s in C:\xampp\htdocs\vendor\google\apiclient\src\Google\Http\REST.php on line 118
Can somebody assist me? Thanks
Upvotes: 7
Views: 13411
Reputation: 61
Some people could meet this issue (in a local environment) when upgrading to Mac OS Catalina. This, upgraded my php version from 7.1 to 7.3, so I had the same issue with CurlFactory (used version 6.2.1 of Guzzle).
This can be fixed by updating your version of Guzzle to 6.3.0 (minimal). How to do this :
"require": {
"guzzlehttp/guzzle": "^6.3.0"
}
Then in a terminal (in the root of your project) :
composer update
OR, if you can't change your Guzzle version (for a reason or another.. This is my case)
Then in a terminal type :
brew update
brew install [email protected]
In some case, you'll have to link to php 7.1 with the following command :
brew link [email protected]
Finally, re-launch your terminal.
Upvotes: 6
Reputation: 98
In my case the issue wasn't critical, after trying the solutions above I got to the conclusion I just needed to remove the errors and everything worked.
if(version_compare(PHP_VERSION, '7.2.0', '>=')) {
error_reporting(E_ALL ^ E_NOTICE ^ E_WARNING);
}
This code is only required on localhost, the production server doesn't output warnings anyway.
Upvotes: 2
Reputation: 2964
I know this is an old post but I have fixed it by updating the Guzzle
via composer.
First add this in your composer
"require": {
"guzzlehttp/guzzle": "~5.3.1"
}
Then write
composer update
in your command prompt
Upvotes: 3
Reputation: 117301
As stated here count(): Parameter must be an array or an object
Please try upgrading your version of Guzzle.
The problem is in PHP 7.2 the parameter for count() can't be NULL. The warning in the first post gets displayed when $this->handles equals NULL. Just replace line 67 in CurlFactory.php with the following:
if (($this->handles ? count($this->handles) : 0) >= $this->maxHandles) {
Upvotes: 9