Http Client

Installs: 4 244

Dependents: 1

Suggesters: 0

Security: 0

Stars: 0

Watchers: 2

Forks: 0

Open Issues: 2

Type:libraries

v1.1.0 2019-06-14 18:42 UTC

README

Installing

composer require buzzina-social/http

Using

require __DIR__.'/vendor/autoload.php';

    class MoreClass extends \BuzzinaSocial\Http\Client
    {
        public function __construct()
        {
            $this->setHeaders( [
                'accept' => 'application/json',
                'Content-Type' => 'application/json'
            ]);

            $this->setBaseURI('https://viacep.com.br/ws/');

            parent::__construct();
        }

        public function test()
        {
            return $this->get('01001000/json/');
        }
    }

    try {
        $more_class = new MoreClass();
        $more_class->test();
    } catch (\Exception $e) {}

    print_r(json_decode($more_class->test()->getBody()));