PHP code example of chriha / rest-client

1. Go to this page and download the library: Download chriha/rest-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/ */

    

chriha / rest-client example snippets


$options = [
    'url' => 'http://api.localhost/v1',
];

$rest = new \Chriha\Clients\Rest( $options );
$rest->get( '/posts' );

$post = [
    "title" => "lorem",
    "body"  => "lorem ipsum dolor set"
];

$rest = new \Chriha\Clients\Rest( $options );
$rest->post( '/posts', $post );

$post = [
    "title" => "lorem"
];

$rest = new \Chriha\Clients\Rest( $options );
$rest->put( '/posts/1', $post );
$rest->patch( '/posts/1', $post );

$rest = new \Chriha\Clients\Rest( $options );
$rest->delete( '/posts/1' );

$options = [
    'allow_self_signed' => true,
];

$options = [
    'curl_options' => [...],
];

$options = [
    'authentication' => 'oauth1',
    'token'          => 'YOUR_API_TOKEN',
    'secret'         => 'YOUR_API_SECRET',
];