1. Go to this page and download the library: Download validakey/validakey-php 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/ */
validakey / validakey-php example snippets
use Validakey\ValidakeyClient;
use Validakey\ValidakeyConfig;
use Validakey\Request\CreateTokenRequest;
$config = new ValidakeyConfig(
baseUrl: getenv('VALIDAKEY_BASE_URL') ?: 'https://example.validakey.host/v1',
apiUUID: getenv('VALIDAKEY_API_UUID') ?: 'your-account-uuid-here',
userAppId: getenv('VALIDAKEY_USER_APP_ID') ?: 'your-user-app-id-here',
apiPKey: getenv('VALIDAKEY_API_PKEY') ?: null,
subject: getenv('VALIDAKEY_SUBJECT') ?: null,
);
$client = new ValidakeyClient($config);
use Validakey\Instance\FileInstanceStore;
$client = new ValidakeyClient(
$config,
null,
new FileInstanceStore('/var/lib/myapp/validakey-instance.json'),
);
$check = $client->verifyToken($token->token);
if (! $check->isValid()) {
exit($check->reason()); // revoked, expired, depleted, not_found
}
echo $check->expiresAt(); // null when the vKey never expires
echo $check->usesRemaining(); // null when it is not use-limited