PHP code example of grandgarage / api-client
1. Go to this page and download the library: Download grandgarage/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/ */
grandgarage / api-client example snippets
// Create request class
$baseUrl = 'https://my-domain.com/api/v1/'; // example domain
$token = 'c4164ac9-703b-4e6b-a3cc-715a0e4dfe7d'; // example token
$request = new Grandgarage\ApiClient\HttpRequest($baseUrl, $token);
// GET request - example
/** @var \Illuminate\Http\JsonResponse $response */
$respone = $request->get('users', [], 'orderBy=desc', 'limit=1000');
// POST request - example
$body = ['name' => 'Max Mustermann'];
$request->post('users', json_encode($body));
// UPDATE request - example
$id = 1;
$body = ['name' => 'Hilde Musterfrau'];
$request->put('users/'.$id, json_encode($body));