PHP code example of adam-innes / php-rest-client

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

    

adam-innes / php-rest-client example snippets



 = new \PhpRestClient\PhpRestClient('http://base.url/to/api/');

$rest = new \PhpRestClient\PhpRestClient('http://base.url/to/api');

/** Get Example **/
# Set custom headers.
$headers = array(
    'CURLOPT_VERBOSE' => true,
);
# The get function will take a query string or array of parameters.
$response = $rest->get('account/information', 'variable=1&variable=2', $headers);

/** Put Example **/
$params['variable_1'] = 'value_1';
$params['variable_2'] = 'value_2';
$response = $rest->put('user/information', $params);

/** Post Example **/
$params['variable_1'] = 'value_1';
$params['variable_2'] = 'value_2';
$response = $rest->post('user/information', $params);

/** Delete Example **/
$response = $rest->delete('delete/user/5');

$rest = new \PhpRestClient\PhpRestClient('http://base.url/to/api');
# Set Basic Authentication Headers.
$rest->setAuthentication('myUsername', 'myPassword', CURLAUTH_DIGEST);
$rest->get('account/information');
# Unset the Authentication headers.
$rest->unsetAuthentication();

$ php composer.phar install

{
    "  "adam-innes/php-rest-client": "1.0.*"
    }
}