PHP code example of protacon / vf-rest

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

    

protacon / vf-rest example snippets





declare(strict_types=1);

namespace App;

use GuzzleHttp\Exception\BadResponseException;
use ValueFrame\Rest\Factory as Client;
use function json_decode;
use function var_dump;

e docs

$client = Client::build($customer, $token, $resource);

try {
    $response = $client->get('');

    var_dump($response->getStatusCode());
    var_dump(json_decode($response->getBody()->getContents()));
} catch (BadResponseException $exception) {
    var_dump($exception->getResponse()->getStatusCode());
    var_dump(json_decode($exception->getResponse()->getBody()->getContents()));
}
bash
# Install Composer
curl -sS https://getcomposer.org/installer | php