PHP code example of timefrontiers / api-auth-client
1. Go to this page and download the library: Download timefrontiers/api-auth-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/ */
timefrontiers / api-auth-client example snippets
use TimeFrontiers\Auth\Client\{ApiClient, Credentials};
$credentials = new Credentials(
app_id: '123',
public_key: 'key-selector-2026-01',
secret_key: $secretFromASecretManager
);
$client = new ApiClient($credentials, 'https://api.example.com');
$response = $client->get('/users', ['status' => 'active', 'limit' => 10]);
$response = $client->post('/users', ['name' => 'John', 'email' => '[email protected] ']);
use TimeFrontiers\Auth\Client\{ApiClient, CurlTransport};
$client = new ApiClient(
credentials: $credentials,
base_url: 'https://api.example.com/v1',
timeout: 30,
default_headers: ['Accept-Language' => 'en'],
verify_ssl: true,
transport: new CurlTransport(),
connect_timeout: 10
);
$response = $client->request(
method: 'POST',
path: '/events?source=manual%20client',
body: '0',
headers: ['Content-Type' => 'text/plain']
);
$client->get('/search', [
'sort' => ['direction' => 'asc', 'by' => 'name'],
'filter' => ['tags' => ['red', 'blue']],
]);
// /search?filter%5Btags%5D%5B0%5D=red
// &filter%5Btags%5D%5B1%5D=blue
// &sort%5Bby%5D=name&sort%5Bdirection%5D=asc
use TimeFrontiers\Auth\Client\Signer;
$headers = Signer::generateHeaders(
$credentials,
method: 'POST',
path: '/api/v1/users?notify=true',
body: '{"name":"John"}'
);
$response = $client->get('/users/123');
$response->isSuccess();
$response->isError(); // every non-2xx, including 3xx
$response->getStatusCode();
$response->json(); // object/array or null
$response->hasJsonError();
$response->isJsonScalar();
$response->get('data.user.name');
$response->getHeader('content-type');
$response->getHeaderValues('set-cookie');
$response->throwIfError();