gpt4 book ai didi

php - Guzzle 错误计数() : Parameter must be an array or an object that implements Countable in

转载 作者:行者123 更新时间:2023-12-03 22:57:50 24 4
gpt4 key购买 nike

我正在关注下面的文章,
https://developers.google.com/analytics/devguides/reporting/core/v3/quickstart/web-php

但是最后,当我尝试使用示例代码(HelloAnalytics.php)时,它会在命令行中显示如下错误并且无法获取数据;

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



有人可以帮助我吗?
谢谢

最佳答案

有些人在升级到 Mac OS Catalina 时可能会遇到这个问题(在本地环境中)。这将我的 php 版本从 7.1 升级到 7.3,所以我在 CurlFactory 上遇到了同样的问题(使用了 Guzzle 的 6.2.1 版本)。
这可以通过将您的 Guzzle 版本更新到 6.3.0(最低)来解决。
如何做到这一点 :

"require": {
"guzzlehttp/guzzle": "^6.3.0"
}
然后在终端中(在项目的根目录中):
composer update
或者,如果您无法更改 Guzzle 版本(出于某种原因或其他原因......这是我的情况)
  • 您可以改为通过安装 7.1 来更改您的 php 版本(在我的示例中使用自制软件。如果您没有它,您可以在此处找到/安装:https://brew.sh/index)

  • 然后在终端类型中:
    brew update
    brew install php@7.1
    在某些情况下,您必须使用以下命令链接到 php 7.1:
    brew link php@7.1
    最后,重新启动您的终端。

    关于php - Guzzle 错误计数() : Parameter must be an array or an object that implements Countable in,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50898330/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com