-
Notifications
You must be signed in to change notification settings - Fork 5
Endpoint: Validate
Alejandro Mostajo edited this page Jan 21, 2019
·
6 revisions
API's validate endpoint will let you validate a license key activated.
$isValid = Api::validate($client, $getClosure, $setClosure);
Parameter | Type | Description |
---|---|---|
$client | Client |
An instance of the client. |
$getClosure |
Closure (callable on php5) |
A function that should return an instance of LicenseRequest . |
$setClosure |
Closure (callable on php5) |
A function used to save or store somewhere the activated license string. |
$force | bool |
Force validation against API. Default: false
|
$allowRetry | bool |
If the is not connection with the server, allow validation to retry later. Default: false
|
$retryAttempts | int |
Amount of connection retries allowed before returning validation as false. Default: w
|
$retryFrequency | string |
When should next retry validation occur. See strtotime() values. Default: +1 hour
|
Type | Description |
---|---|
bool |
Flag indicating if license key is valid or not. |
The following example will show how to validate an activated license key and how to update its license string.
$isValid = Api::validate(
Client::instance(), // Client instance
function() {
// ---------------------------------------------
// Code here...
// Code to load the LICENSE STRING saved on activation.
// Apply decryption if necessary.
// ---------------------------------------------
// MUST RETURN AN INSTANCE OF LicenseRequest
return new LicenseRequest($licenseString);
}, // getClosure
function($licenseString) {
// ---------------------------------------------
// Code here...
// Code to update the LICENSE STRING saved on activation.
// Apply encryption if necessary.
// ---------------------------------------------
// as sample
update_license($licenseString);
} // setClosure
);
Make sure to store and update the $licenseString
in somewhere safe. Add your encryption/decryption method of choice if necessary.
NOTE: The client will only validate against the API based on the frequency set during activation. When not validating against the API directly, the client will validate the license key with the data retrieved and stored in the license string.
You might want to allow retries, this will help keep your product valid of time if your license key server is down for any reason.