PHP Обращение к неопределенному методу - PullRequest
0 голосов
/ 05 мая 2020

Я пытаюсь использовать этот репозиторий 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();
        }
    }

}

Все composer зависимости уже установлены, но выдает ошибку, у кого-нибудь есть решение?

1 Ответ

1 голос
/ 05 мая 2020

Пробовали без метода запроса?

$this->client->post($url, []);

Какую версию жрать вы используете?

...