2017 © Pedro Peláez
 

library api

Shortcut for making http api calls

image

paulbunyannet/api

Shortcut for making http api calls

  • Thursday, June 29, 2017
  • by paulbunyannet
  • Repository
  • 2 Watchers
  • 0 Stars
  • 509 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 14 Versions
  • 39 % Grown

The README.md

paulbunyannet/api

Build Status Latest Version Coverage Status, (*1)

paulbunyannet/api Shortcut for making http calls to json endpoint, (*2)

Installation

This project can be installed via [Composer]:, (*3)

``` bash $ composer require paulbunyannet/api:^1.0, (*4)


## Request Methods: ### Get ```php $getArgs = ['something' => ,'something_else']; $get = new Get('https://pathtoapi.com/get/?'.http_build_query($getArgs)); $retrieve = $get->retrieve(); var_dump($retrieve); // { "some_response_key" => "some_response_value" }
$getArgs = ['something' => ,'something_else']; 
$get = new Get('https://pathtoapi.com/get/?'.http_build_query($getArgs));
$retrieve = $get->retrieve();
var_dump($retrieve); // { "some_response_key" => "some_response_value" }

Post

$postArgs = ['something' => ,'something_else']; 
$post = new Post('https://pathtoapi.com/post');
$retrieve = $post->retrieve($postArgs);
var_dump($retrieve); // { "some_response_key" => "some_response_value" }

Put

$postArgs = ['something' => ,'something_else']; 
$put = new Put('https://pathtoapi.com/put');
$retrieve = $put->retrieve($postArgs);
var_dump($retrieve); // { "some_response_key" => "some_response_value" }

Delete

$delete = new Put('https://pathtoapi.com/delete/user/1');
$retrieve = $delete->retrieve();
var_dump($retrieve); // { "success" => "true" }

Headers

Header array can be passed into a new object:, (*5)

$getArgs = ['something' => ,'something_else']; 
$get = new Get('https://pathtoapi.com/get/?'.http_build_query($getArgs));
// headers to pass with request
$get->setHeaders(['headerKey' => 'headerValue']);
$retrieve = $get->retrieve();
var_dump($retrieve); // { "some_response_key" => "some_response_value" }

The header "headerKey: headerValue" will then be passed on with the REST request, (*6)

Authentication

Each request method can use payload authentication and then check that payload on the receiving end, (*7)

// on the sender side:
$postArgs = ['something' => ,'something_else'];
$identity = 'my-user-name'; // used for looking up private key on the receiving side
$privateKey = "my-super-secret-key";
$post = new Post('https://pathtoapi.com/post');
$post->setPayload([Auth\AuthBootstrap::IDENTITY => $identity, Auth\AuthBootstrap::PRIVATEKEY => $privateKey]);
$retrieve = $post->retrieve($postArgs);

// then on the receiving side:
$lookUpPrivateKey = 'my-super-secret-key'; // this is where you would do a lookup for user's private key by the ideney key that was sent with the request
$receiver = new Auth\Receive($_POST['payload'], $lookUpPrivateKey);
$verifyHash = receiver->verifyHash($_POST); // will return true if payload hash sent is correct

The Versions

29/06 2017

dev-master

9999999-dev

Shortcut for making http api calls

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

by naten

29/06 2017

1.5.1

1.5.1.0

Shortcut for making http api calls

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

by naten

02/07 2016

1.5.0

1.5.0.0

Shortcut for making http api calls

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

by naten

02/07 2016

1.4.03

1.4.03.0

Shortcut for making http api calls

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

by naten

02/07 2016

1.4.021

1.4.021.0

Shortcut for making http api calls

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

by naten

02/07 2016

1.4.02

1.4.02.0

Shortcut for making http api calls

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

by naten

02/07 2016

1.4.01

1.4.01.0

Shortcut for making http api calls

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

by naten

02/07 2016

1.4.0

1.4.0.0

Shortcut for making http api calls

  Sources   Download

MIT

The Requires

  • php >=5.6.0

 

The Development Requires

by naten

22/09 2015

1.3.0

1.3.0.0

Shortcut for making http api calls

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

by naten

17/09 2015

1.2.2

1.2.2.0

Shortcut for making http api calls

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

by naten

17/09 2015

1.2.1

1.2.1.0

Shortcut for making http api calls

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

by naten

15/09 2015

1.2.0

1.2.0.0

Shortcut for making http api calls

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

by naten

15/09 2015

1.1.0

1.1.0.0

Shortcut for making http api calls

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

by naten

14/09 2015

1.0.0

1.0.0.0

Shortcut for making http api calls

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

by naten