0

I am trying to use this github repository https://github.com/otaviobarreto/dlocal-php but I am getting a error on Guzzle

Call to undefined method GuzzleHttp\Client::request()

Here is the php code:

<?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();
        }
    }

}

All composer dependences was already installed but it keeps getting error, does somebody have a solution?

1 Answer 1

1

Did you try without request method ?

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

Which version of guzzle you're using ?

Sign up to request clarification or add additional context in comments.

2 Comments

I am using version guzzlehttp/guzzle5.1, let me try
$this->client->post($url, []); gives me a Parse error

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.