Weblutions Documentation
Weblutions Main Site Contact Us Our Discord
Some pages are still pending proper formatting, if required refer to the legacy documentation website.
FaxStore IconFaxStore

Weblutions Documentation / FaxStore / License System Examples

Updated

License System Examples

By Josh M. 1 mins 4

The following examples demonstrate how an application can send a request to the FaxStore License System API to verify a license key.

Table of Contents


License Validation Endpoint

POST/api/check/PRODUCT_ID
The API returns a JSON response indicating whether the license is valid.
Authorization
AuthorizationStringrequired
The license key issued for the product
Content-TypeStringrequired
Typically 'application/json'
Responses
200OKjson
{
  "status": "AUTHORISED",
  "pass": true,
  "details": "Authorisation completed - https://license.example.com"
}

Node.js (Fetch API)

The Fetch API is available natively in Node.js v18 and newer. Older versions of Node.js may require the node-fetch package.

const url = 'https://license.example.com/api/check/PRODUCT_ID';

const options = {
    method: 'POST',
    headers: {
        'Content-Type': 'application/json',
        'Authorization': 'LICENSE_KEY',
    }
};

fetch(url, options).then(response => response.json())
.then(data => {
    console.log(data);
}).catch(error => {
    console.error('Error:', error);
});

Lua

local productId = 1
local licenseKey = 'ABC_123'

PerformHttpRequest("https://license.example.com/api/check/" .. productId, function(errorCode, resultData, resultHeaders)

    local data = json.decode(resultData)

    if data['pass'] then        
        print('^2Authorisation completed!^7')            
    else
        print('^1' .. data.details .. '^7')
        os.exit(0)
    end

end, "POST", "", {
    ["Accept"] = "application/json, text/plain, */*",
    ["User-Agent"] = "*",
    ["Authorization"] = licenseKey
})

PHP

<?php

$url = "https://license.example.com/api/check/9"; // 9 is the product ID
$license = "ABC_123";

$curl = curl_init();

curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);

$headers = array(
   "Accept: application/json",
   "Content-Type: application/json",
   "Authorization: $license",
);

curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);

$resp = curl_exec($curl);

curl_close($curl);

$data = json_decode($resp);

if ($data->pass == true) {
    echo "License Passed";
} else {
    echo "License Failed";
    exit;
}
?>

Python (http.client)

import http.client

conn = http.client.HTTPSConnection("license.example.com")

payload = ""

headers = {
    'Authorization': "LICENSE_KEY",
    'Accept': "application/json"
}

conn.request("POST", "/api/check/1?info=INFO_FOR_REQUEST_OPTIONAL", payload, headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))

PowerShell

$headers=@{}
$headers.Add("Authorization", "LICENSE_KEY")
$headers.Add("Accept", "application/json")

$response = Invoke-WebRequest `
    -Uri 'https://license.example.com/api/check/1?info=INFO_FOR_REQUEST_OPTIONAL' `
    -Method POST `
    -Headers $headers

Version 1 API request formats have been removed. The examples above reflect the current license API structure used by FaxStore.