1. Go to this page and download the library: Download dominionenterprises/tol-api 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/ */
dominionenterprises / tol-api example snippets
use TraderInteractive\Api;
$apiAdapter = new Api\GuzzleAdapter();
$auth = Api\Authentication::createClientCredentials(
'clientId',
'clientSecret'
)
$apiClient = new Api\Client(
$apiAdapter,
$auth,
'https://baseApiUrl/v1'
);
<li>
$response = $apiClient->index(
'resourceName',
array('aFilter' => '5')
);
if ($response->getStatusCode() !== 200) {
throw new Exception('Non successful index call');
}
$body = json_decode($response->getBody(), true);
$total = $body['pagination']['total'];
// Loop over the first page of items
foreach ($body['result'] as $item) {
echo "<li>{$item['foo']}</li>\n";
}
// Get item 1234
$response = $apiClient->get('resourceName', '1234');
if ($response->getStatusCode() !== 200) {
throw new Exception('Failed to fetch item 1234');
}
$item = json_decode($response->getBody(), true);
echo "Fetched item {$item['foo']}\n";