【发布时间】:2020-08-20 06:55:48
【问题描述】:
我正在尝试使用这个 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();
}
}
}
所有的作曲家依赖都已经安装了,但是一直报错,有人有解决办法吗?
【问题讨论】: