php - PHP Guzzle 调用未定义的方法
问题描述
我正在尝试使用这个 github 存储库 https://github.com/otaviobarreto/dlocal-php但我在 Guzzle 上遇到错误
调用未定义的方法 GuzzleHttp\Client::request()
这是php代码:
<?php
namespace Fripixel\DLocal\Core;
use GuzzleHttp\Client;
use GuzzleHttp\Exception\ClientException;
class Request
{
public $client = null;
public $baseURI = null;
public $timeout = 2.0;
public function __construct($config, $debug = false)
{
$this->client = new Client([
'base_uri' => $config->base_uri,
'timeout' => $this->timeout,
'debug' => $debug,
]);
$this->baseURI = $config->base_uri;
}
public function get($url, $headers)
{
try {
$response = $this->client->request("GET", $url, [
"headers" => $headers,
]);
return $response->getBody();
} catch (ClientException $e) {
return $e->getResponse()->getBody();
}
}
public function post($url, $headers, $body)
{
try {
$response = $this->client->request("POST", $url, [
"headers" => $headers,
"json" => $body,
]);
return $response->getBody();
} catch (ClientException $e) {
return $e->getResponse()->getBody();
}
}
}
所有作曲家依赖项都已安装,但一直出错,有人有解决方案吗?
解决方案
你试过没有请求方法吗?
$this->client->post($url, []);
您使用的是哪个版本的 guzzle?
推荐阅读
- c# - ASP.NET 用户不会出现在 SSMS 中
- java - 无法使用 SAX 解析器捕获元素
- linux - 双引号bash脚本linux
- python-3.x - 如何将多个单元格添加到bigtable表格中的一行?
- regex - 在 Notepad++ 中使用正则表达式在第二个冒号后擦除
- ssas - SSAS Cubes 在本地机器上处理,但不在服务器上
- html - 如何使用 VBA 从以下页面抓取邮件
- javascript - Meteor - 在methods.js中导入变量后错误阻止启动
- python - 尝试从十六进制转换为二进制时出现“列表对象不可调用”错误
- .net-core - .NET Core 世界中是否有类似于 Laravel tinker 的东西?