2017 © Pedro Peláez
 

library api_client

Basic API client

image

arikin/api_client

Basic API client

  • Tuesday, October 10, 2017
  • by arikin
  • Repository
  • 1 Watchers
  • 0 Stars
  • 5 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

api_client

Simple PHP API Client using GuzzleHttp 6, (*1)

Overview

A RESTful API in PHP 7 and the new GuzzleHttp 6. This is a conversion of an old project from version 4 of guzzle to the latest version 6 guzzlehttp/guzzle, (*2)

Returns an API object of Guzzle. Create a class that understands the API commands for the given API server. Then use this API object to execute get, post, and etc., (*3)

Installation

Require it in your project, (*4)

php composer.phar require arikin/api_client

Usage

Require the class and initialize it with the API server's base URL and the credentials., (*5)

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

use Arikin\ApiClient;

$client = new ApiClient(array(
    'url' => 'http://api.server.net',
    'user' => 'api_username',
    'pass' => 'secret_password'
 ));

$resp_obj = $client->api->get('/user/list');
$code = $resp_obj->getStatusCode();
$reason = $resp_obj->getReasonPhrase();

$body_string = (string) $resp_obj->getBody();
$data_array = json_decode($body_string,TRUE);

The Versions

10/10 2017

dev-master

9999999-dev

Basic API client

  Sources   Download

MIT

The Requires

 

10/10 2017

0.1.4

0.1.4.0

Basic API client

  Sources   Download

MIT

The Requires

 

10/10 2017

0.1.3

0.1.3.0

Basic API client

  Sources   Download

MIT

The Requires