PHP code example of fisafe / api-client

1. Go to this page and download the library: Download fisafe/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/ */

    

fisafe / api-client example snippets




use Fisafe\ApiClient;


$fisafeClient = new ApiClient(
    'https://auth.fisafe.cloud',
    'used_realm',
    'used_client_id',
    'your_username'
    'your_password'
);

$fisafeClient->setApiUrl('https://organization-domain.fisplay.cloud/v1/api/');

$user = $fisafeClient->createUser('my-user-identifier');
echo "User created with ID: {$user->id}" . PHP_EOL;

$identifierType = 'rfid-tag';  // Choose from 'pin', 'rfid-tag', or 'licence-plate'
$identifierValue = '121212121';
$identifier = $fisafeClient->createIdentifer($user->id, $identifierValue, $identifierType);
echo "Identifier {$identifierValue} of type {$identifierType} created for User ID: {$user->id}" . PHP_EOL;

$filteredUsers = $fisafeClient->listUsers(['identifier' => 'my-user-identifier']);
echo "List of users with identifier 'my-user-identifier':" . PHP_EOL;
var_dump($filteredUsers);

$contextId = 12345;  // Example context ID
$fromDate = new DateTime('now');
$toDate = new DateTime('+1 month');
$access = $fisafeClient->createGrantedAccess($contextId, $user->id, $fromDate, $toDate);
echo "Access granted to context {$contextId} from {$fromDate->format('Y-m-d')} to {$toDate->format('Y-m-d')}" . PHP_EOL;