PHP code example of brofist / json-api-client

1. Go to this page and download the library: Download brofist/json-api-client library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

brofist / json-api-client example snippets


use Brofist\ApiClient\Json;

$client = new Json([
    'endpoint' => 'http://foo.bar/v1/blah',
    // optional
    'basicAuth' => ['username', 'password'],
]);
 
// basic usage:
$resources = $client->get('/resources', [
    'limit' => 100,
]);
 
$resources = $client->put('/resources/1', [
    'name' => 'foo',
]);
 
$resources = $client->post('/resources', [
    'name' => 'foo',
]);
 
// with optionally supplied custom options per-request:
$resources = $client->post(
    '/resources',
    ['name' => 'foo'],
    ['headers' => ['X-Request-Token' => 'e4d909c290d0fb1ca068ffaddf22cbd0']]
);