PHP code example of infinitum / php-sdk
1. Go to this page and download the library: Download infinitum/php-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/ */
infinitum / php-sdk example snippets
$infinitum = new \Fyi\Infinitum\Infinitum($workspace, $token, $identity);
if (Session::get('access_token')) {
$access_token = Session::get('access_token');
$infinitum->setAccessToken($access_token);
} else {
try {
$response = $infinitum->init();
$access_token = $response["access_token"];
Session::put('access_token', $access_token);
} catch (\Fyi\Infinitum\Exceptions\InfinitumAPIException $exc) { } catch (\Fyi\Infinitum\Exceptions\InfinitumSDKException $exc) { }
}
use \Fyi\Infinitum\Infinitum;
$infinitum = new Infinitum($workspace, $token, $key, $secret);
$infinitum->init();
$userAPI = $infinitum->user();
$userAPI = $infinitum->user();
$data = [
"name" => "SDK User name",
"password" => "password123",
"email" => "[email protected] ",
"photo" => File,
"photo64" => "data:image/png;base64,.....",
"birthdate" => "1/1/1970",
"language" => "en-US"
];
$response = $userAPI->register($data);
$data = [
"photo" => File,
"photo64" => "data:image/png;base64,.....",
];
$response = $userAPI->face($data);
$data = [
"email" => "[email protected] ",
];
$response = $userAPI->getByEmail($data);
$response = $userAPI->getUsers();
$data = [
"id" => 1
];
$response = $userAPI->deleteUser($data);
$data = [
'action' => 'infinitum-password-reset', // > 'Conent example',
'to' => '[email protected] ',
'from' => '[email protected] ',
'lang' => 'pt-PT'
];
$response = $userAPI->notify($data);
$deviceAPI = $infinitum->device();
$data = [
"name" => "SDK Device",
"mac_address" => "AA:BB:CC:DD:EE:FF",
"ip" => "192.168.1.2",
"identity" => "device-unique-identity",
"app_id" => "1",
"device_type" => "PC",
"licensed" => "",
"app_version" => ""
];
$response = $deviceAPI->registerDevice($data);
$data = [
"device_mac_address" => "AA:BB:CC:DD:EE:FF",
"user_email" => "[email protected] ",
"device_id" => "1",
"user_id" => "1"
];
$response = $deviceAPI->registerDeviceUser($data);
$data = [
"mac_address" => "AA:BB:CC:DD:EE:FF",
"app_id" => "1",
"licensed" => "1", # can be 0, 1, true or false
];
$response = $deviceAPI->license($data);
$data = [
"mac_address" => "AA:BB:CC:DD:EE:FF",
];
$response = $deviceAPI->validate($data);
$data = [
"id" => 1
];
$response = $deviceAPI->deleteDevice($data);
$authAPI = $infinitum->auth();
$data = [
"photo" => $file,
"photo64" => "data:image/png;base64,....",
"device" => 1,
"device_ip" => "192.168.1.2",
"device_mac_address" => "AA:BB:CC:DD:EE:FF",
"device_mac_address_value" => "extended-parameter",
"action" => "entrance",
"proximity" => "near",
"data" => [] # additional custom parameters
];
$response = $deviceAPI->biometric($data);
$data = [
"email" => "[email protected] ",
"password" => "password123"
];
$response = $deviceAPI->login($data);
$data = [
"used_codes" => [
["code" => "abc1", "date" => "01-01-2019 18:00:00"],
["code" => "abc12", "date" => "01-01-2019 18:00:00"]
],
"device_mac_address" => "AA:BB:CC:DD:EE:FF"
];
$response = $deviceAPI->code($data);
$authAPI = $infinitum->cms();
[
"message" => "The provided email has already been taken.",
"type" => "VALIDATOR_ERROR",
"status" => 400
]
try {
$response = $deviceAPI->biometric([
"photo" => $file,
]);
// (...)
} catch (\Fyi\Infinitum\Exceptions\InfinitumAPIException $exc) {
return $exc->getBody();
}
try {
$response = $userAPI->getByEmail([]);
// (...)
} catch (\Fyi\Infinitum\Exceptions\InfinitumSDKException $exc) {
return $exc->getMessage();
}
try {
$response = $userAPI->register($data);
// (...)
} catch (\Fyi\Infinitum\Exceptions\MissingTokenException $exc || \Fyi\Infinitum\Exceptions\InfinitumSDKException $exc ) {
return $exc->getMessage();
}
composer