2017 © Pedro Peláez
 

library op-restclient

A generic REST API client for PHP using objects to compose requests

image

ocjojo/op-restclient

A generic REST API client for PHP using objects to compose requests

  • Sunday, September 3, 2017
  • by ocjojo
  • Repository
  • 1 Watchers
  • 0 Stars
  • 15 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

OP-Restclient

OOP - Object-oriented programming
PHP
REST-Client, (*1)

A generic REST API client for PHP using objects to compose requests. This is based on and extends the excellent tcdent/php-restclient., (*2)

https://github.com/ocjojo/op-restclient (c) 2017 Lukas Ehnle me@ehnle.fyi, (*3)

Installation

``` sh $ composer require ocjojo/op-restclient, (*4)



## Basic Usage ``` php $api = new OPRestclient\Client([ 'base_url' => "https://jsonplaceholder.typicode.com" ]); // GET https://jsonplaceholder.typicode.com/posts/1?param_1=hello&param_2=world $result = $api->posts->{1}->get([ 'param_1' => "hello", 'param_2' => "world" ]); if($result->info->http_code == 200) var_dump($result->decode_response());

Options for the client

See the documentation of tcdent/php-restclient for the configurable options. OPRestClient extends tcdent's RestClient, so all options and methods apply equally., (*5)

Standard Parameters

You are able to set standard parameters for consecutive requests to the same endpoint, e.g. if you want access data at an endpoint with paging. Like so:, (*6)

``` php $api = new OPRestClient\Client([ 'base_url' => "https://api.twitter.com/1.1", 'format' => "json", // https://dev.twitter.com/docs/auth/application-only-auth 'headers' => ['Authorization' => 'Bearer '.OAUTH_BEARER] ]);, (*7)

$api->search->tweets['q'] = '#php'; //both results will have the query parameter q set to '#php' $result = $api->search->tweets->get(['page' => '1']); $result2 = $api->search->tweets->get(['page' => '2']);, (*8)

// to delete a standard parameter of a route unset($api->search->tweets['q']);, (*9)

// to delete all standard parameters of a route $api->search->tweets->reset(); ```, (*10)

Standard Parameters will be set until you unset them manually., (*11)

The Versions

03/09 2017

dev-master

9999999-dev

A generic REST API client for PHP using objects to compose requests

  Sources   Download

MIT

The Requires

 

by Lukas Ehnle

03/09 2017

0.0.1

0.0.1.0

A generic REST API client for PHP using objects to compose requests

  Sources   Download

MIT

The Requires

 

by Lukas Ehnle