PHP code example of codesbytvt / token-management-sdk
1. Go to this page and download the library: Download codesbytvt/token-management-sdk 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/ */
codesbytvt / token-management-sdk example snippets
okenManagement\SDK\TokenClient;
// Initialize the client
// Option 1: User Authentication (JWT)
// For cloud deployment
$client = new TokenClient([
'base_url' => 'https://api.yourdomain.com'
]);
// For local subdirectory deployment (e.g., MAMP, XAMPP)
$client = new TokenClient([
'base_url' => 'http://localhost/api.token-management'
]);
// Option 2: Client Authentication (API Key/Secret)
// Best for Kiosks, Displays, and Machine-to-Machine
$client = new TokenClient([
'base_url' => 'https://api.yourdomain.com', // or http://localhost/api.token-management
'client_id' => 'YOUR_CLIENT_ID',
'client_secret' => 'YOUR_CLIENT_SECRET'
]);
// Authenticate
$auth = $client->auth()->signIn('[email protected]', 'password');
$client->setAccessToken($auth->getAccessToken());
// Issue a token
$token = $client->tokens()->issue([
'mlocation_id' => 1,
'mservicepoint_id' => 2,
'mtokencategory_id' => 1,
'customer_name' => 'John Doe'
]);
echo "Token Number: " . $token->getTokenNumber();
try {
$health = $client->health();
echo "API Status: " . $health['status'];
// Output: API Status: ok
} catch (\Exception $e) {
echo "API is down: " . $e->getMessage();
}