lukaszjarosinski/restclient

Simple and fast rest client

dev-master 2022-01-20 11:42 UTC

This package is not auto-updated.

Last update: 2024-09-27 23:52:24 UTC


README

https://github.com/lukaszjarosinski/restclient (c) 2022 lukaszjarosinski@gmail.com

Installation

$ php composer.phar require lukaszjarosinski/restclient

Basic Usage

$client = new Client();
$headers = array("Content-Type" => "application/x-www-form-urlencoded"); //example headers, unnecessary
$parameters = array('name'=>'Name','gender'=>'male','email'=>'email@email.com','status'=>'active'); //example parameters, unnecessary
$client->get('http://www.boredapi.com/api/activity'); //url
  echo "<pre>";
  var_dump($client->returnResponse());
  echo "</pre>";

Configurable Options

headers - An associative array of HTTP headers and values to be included in every request.
parameters - An associative array of URL or body parameters to be included in every request.
user_agent - User agent string to use in requests.
username - Username to use for HTTP basic authentication. Requires password.
password - Password to use for HTTP basic authentication. Requires username.

Supported methods

The tool supports methods GET, POST, PATCH, DELETE. Examples:

$client->get('http://www.boredapi.com/api/activity');
$client->post('https://gorest.co.in/public/v1/users',array('name'=>'Name','gender'=>'male','email'=>'email@email.com','status'=>'active'),array('Authorization'=>'Bearer '.$token));