This is a sample implementation to test your license server API. Enter a license key to verify.
An API key is now required for all license verification requests. This enhances security by ensuring only authorized applications can verify licenses.
You can create and manage API keys in your user dashboard.
/**
* PHP License Verification Example
*/
function verifyLicense($licenseKey, $machineId, $apiKey) {
// API endpoint URL
$apiUrl = 'https://getlicensetool.shop/api/verify.php';
// Prepare request data
$data = json_encode([
'license_key' => $licenseKey,
'machine_id' => $machineId
]);
// Initialize cURL session
$ch = curl_init($apiUrl);
// Set cURL options
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); // Follow HTTP redirects
curl_setopt($ch, CURLOPT_MAXREDIRS, 5); // Maximum number of redirects to follow
curl_setopt($ch, CURLOPT_TIMEOUT, 30); // Set a timeout
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Content-Type: application/json',
'Content-Length: ' . strlen($data),
'X-API-Key: ' . $apiKey
]);
// Execute cURL request
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
// Close cURL session
curl_close($ch);
// Check for errors
if ($response === false) {
$curlError = curl_error($ch);
return [
'valid' => false,
'message' => 'Failed to connect to license server: ' . htmlspecialchars($curlError)
];
} else if ($httpCode === 200) {
return json_decode($response, true);
} else {
return [
'valid' => false,
'message' => 'Failed to verify license. HTTP Code: ' . $httpCode
];
}
}
// Usage example
$licenseKey = 'XXXX-XXXX-XXXX-XXXX'; // Your license key
$machineId = md5(php_uname('n')); // Generate machine ID based on hostname
$apiKey = ''; // Replace with your actual API key
$result = verifyLicense($licenseKey, $machineId, $apiKey);
if ($result['valid']) {
echo "License is valid! Expires in {$result['expires_in_days']} days.";
} else {
echo "License verification failed: {$result['message']}";
}
"""
Python License Verification Example
"""
import json
import requests
import uuid
import socket
import hashlib
def verify_license(license_key, machine_id, api_key):
"""Verify license with the license server"""
api_url = 'https://getlicensetool.shop/api/verify.php'
# Prepare request data
data = {
'license_key': license_key,
'machine_id': machine_id
}
try:
# Send POST request to license server
response = requests.post(
api_url,
data=json.dumps(data),
headers={
'Content-Type': 'application/json',
'X-API-Key': api_key
}
)
# Check if request was successful
if response.status_code == 200:
return response.json()
elif response.status_code == 401:
return {
'valid': False,
'message': 'API key is invalid or missing'
}
else:
return {
'valid': False,
'message': f'Failed to verify license. HTTP Code: {response.status_code}'
}
except Exception as e:
return {
'valid': False,
'message': f'Error: {str(e)}'
}
def get_machine_id():
"""Generate a unique machine ID"""
# Get hostname and MAC address
hostname = socket.gethostname()
mac_address = uuid.getnode()
# Combine them and create an MD5 hash
machine_str = f"{hostname}:{mac_address}"
machine_id = hashlib.md5(machine_str.encode()).hexdigest()
return machine_id
# Usage example
if __name__ == '__main__':
license_key = 'XXXX-XXXX-XXXX-XXXX' # Your license key
machine_id = get_machine_id()
api_key = '' # Replace with your actual API key
result = verify_license(license_key, machine_id, api_key)
if result['valid']:
print(f"License is valid! Expires in {result['expires_in_days']} days.")
else:
print(f"License verification failed: {result['message']}")
/**
* Node.js License Verification Example
*/
const axios = require('axios');
const os = require('os');
const crypto = require('crypto');
/**
* Verify license with the license server
*/
async function verifyLicense(licenseKey, machineId, apiKey) {
// API endpoint URL
const apiUrl = 'https://getlicensetool.shop/api/verify.php';
// Prepare request data
const data = {
license_key: licenseKey,
machine_id: machineId
};
try {
// Send POST request to license server
const response = await axios.post(apiUrl, data, {
headers: {
'Content-Type': 'application/json',
'X-API-Key': apiKey
}
});
// Return the response data
return response.data;
} catch (error) {
// Check for specific error codes
if (error.response && error.response.status === 401) {
return {
valid: false,
message: 'API key is invalid or missing'
};
}
return {
valid: false,
message: `Error: ${error.message}`
};
}
}
/**
* Generate a unique machine ID
*/
function getMachineId() {
// Get hostname and network interfaces
const hostname = os.hostname();
const networkInterfaces = os.networkInterfaces();
// Get the first MAC address we can find
let macAddress = '';
Object.keys(networkInterfaces).forEach((ifaceName) => {
if (macAddress) return;
networkInterfaces[ifaceName].forEach((iface) => {
if (macAddress) return;
if (iface.mac && iface.mac !== '00:00:00:00:00:00') {
macAddress = iface.mac;
}
});
});
// Combine hostname and MAC address and create MD5 hash
const machineStr = `${hostname}:${macAddress}`;
const machineId = crypto.createHash('md5').update(machineStr).digest('hex');
return machineId;
}
// Usage example
const licenseKey = 'XXXX-XXXX-XXXX-XXXX'; // Your license key
const machineId = getMachineId();
const apiKey = ''; // Replace with your actual API key
verifyLicense(licenseKey, machineId, apiKey)
.then(result => {
if (result.valid) {
console.log(`License is valid! Expires in ${result.expires_in_days} days.`);
} else {
console.log(`License verification failed: ${result.message}`);
}
})
.catch(error => {
console.error('Error:', error);
});