PHP Example
Please note these are examples. It is recommended that you make one that is more complex and adjustable to your needs.
In this example we will use 'cURL', a PHP dependency that makes our job easier for making requests and of great quality.
Before writing purposeless code, we will properly inform ourselves about the responses returned by the system.
INVALID_SECRET: This error is due to the lack of the required 'PUBLIC_SECRET' for validation.
INCORRECT_SECRET: We should already understand this — this error is due to a mismatch between the PUBLIC_SECRET and the secret sent to validate the key.
Disallowed method: Since validations only work with the POST method, any other attempt like GET will return 'disallowed method'.
Unsupported content type: Since each validation has a unique type for key verification, using a different one will return 'Unsupported content type'.
KEY_UNKNOWN: This error means the key does not exist in the database for validation. Without an existing key, validation will not work under any circumstance.
KEY_EXPIRED: This error is returned when the key passes the existence check, indicating that the key has already expired and cannot be used for validation, unless it is set to never expire or the expiration date is updated.
RESOURCE_UNKNOWN: If the key is required to have a resource and the requesting resource is named 'Blusters' but the key contains the resource 'Bluster', it will not pass for security due to the resource mismatch.
KEY_DISABLED: This can be applied by the clients themselves. This error means the license is offline and cannot be validated unless it is reactivated in the system either by an administrator or the client.
IP_LIMIT: The key has reached the IP limit per license.
HWID_LIMIT: The key has reached the HWID limit per license.
VERSION_INVALID: This means the resource has a different version. To disable version verification, do not complete the 'version' column or avoid marking the resource version as required.
Example of PHP code for validation:
Response code:
405: Disallowed method.
415: Unsupported content type.
401: Invalid Secret.
402: Incorrect Secret.
Clearly, the example is intended to show you the results to check for any issues and such. If you need to perform validation, you'll have to do it yourself to better adapt it to your resource. The same goes for adding the custom or version.
Last updated