PHP code example of opensmarty / rest-api-client

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

    

opensmarty / rest-api-client example snippets

 php
    'providers' => [
        ...
        Opensmarty\Rest\RestClientServiceProvider::class,
        ...
    ],
 bash
php artisan vendor:publish
 php
$restClient = new \Opensmarty\Rest\RestClient('Opensmarty-starter');

$restClient->setOAuthUserCredentials([
    'username' => '[email protected]',
    'password' => 'Abc12345',
]);
$restClient->withOAuthTokenTypeUser();

$response = $restClient->get("users")->getResponse();
if (!$restClient->isResponseStatusCode(200)) {
    $restClient->printResponseOriginContent();
    $responseMessage = $restClient->getResponseMessage();
    print_r($responseMessage);
} else {
    $responseData = $restClient->getResponseData();
    print_r($responseData);
}