1. Go to this page and download the library: Download clarus-it/http-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/ */
clarus-it / http-client example snippets
// baseUri adalah base dari endpoint API, termasuk akhiran /api/
$baseUri = 'https://example.com/api/';
// apiKey adalah api key yang digenerate oleh aplikasi
$apiKey = '4e85a111bf36d87fea86f6452f5084a1bb7820b9605a18b217e3950eb5ea12c1';
// instantiasi objek ClarusHttpClient dengan parameter apiKey dan baseUri
$client = new ClarusHttpClient($apiKey, $baseUri);
// melakukan request GET ke https://example.com/api/ping
// client akan secara otomatis melakukan login apabila belum login, atau jika
// tokennya sudah kedaluarsa
$response = $client->request('GET', 'ping');
// mendapatkan hasilnya sebagai array
$result = $response->toArray();
$client = // client yang sudah diinisialisasi, lihat contoh di atas
$endpoint = '/api/foo/01902fd6-e555-47eb-4761-fc2e9e48b2b5';
$iterator = new PaginationIterator($client, $endpoint);
foreach ($iterator as $item) {
// $item adalah data yang diterima dari endpoint berbentuk array
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.