1. Go to this page and download the library: Download demi/php-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/ */
demi / php-api-client example snippets
$client = new \demi\api\Client([
'baseUri' => 'https://google.com/api/',
'timeout' => 30,
'defaultHeaders' => [],
'defaultQueryParams' => [],
]);
// Simple example: get index page content
$content = $client->get('http://example.com/index.php')->send()->body();
// Make request to baseUri + 'users'
$request = $client->post('users')
->setQueryParam('id', 123) // Single param
->setQueryParam(['name' => 'Jack', 'company' => 'Google']) // Params array
->setPostParam('password', '12345') // Single POST param
->setPostParam(['email' => 'example@com', 'location' => 'London']) // POST params array
->setHeaderParam('Connection', 'Keep-Alive') // Header value
->setHeaderParam(['Accept' => 'image/gif', 'Some-Custom' => 'value']); // Headers array
// Resets
$request->queryParams = []; // Reset query params
$request->formParams = []; // Reset post params
$request->headerParams = []; // Reser headers
// Submit request and get Response object
$response = $request->send();