Javascript/Typescript
Use TypeScript or JavaScript for this function.
Methods through front-end are completely insecure. It is recommended to use back-end for high development and security standards.
async function checkLicense() {
try {
const response = await fetch("https://license.example.com/api.php?secret={$secret}&type=license&key={$key}&scope={$scope}");
const data = await response.json();
if (data.valid) {
// License is valid
console.log('Success');
} else {
// License is invalid
console.log('Error... Access denied!');
if (data.message) {
console.log('Type: ' + data.message);
}
}
} catch (error) {
console.error('Error fetching license:', error);
}
}
checkLicense();
Need for changes to ensure proper functionality.
Fill in the necessary fields.
{$secret} = The secret key of the site to which you will allow access, found in config.php
{$key} = A generated license key.
{$scope} = If the use of scope in the license is mandatory, enter the SCOPE set in the key.
Done.
Last updated