FaxStore

Prerequisites
Installation & Setup
API
Config File
Developer Mode
Enable Debug Mode
Events
Extensions
Features
Integrations
License System Extension
Permissions
Updating FaxStore

Weblutions Documentation > FaxStore > License System Extension > Examples

Examples

Here are some examples of the license system request that can be made to the license system from your application.

Node JS (Using native HTTP)

var options = {
    hostname: 'license.example.com',
    port: 443,
    path: '/api/check/PRODUCT_ID',
    method: 'POST',
    headers: {
         'Content-Type': 'application/json',
         'Authorization': 'LICENSE_KEY',
    }
};
var req = https.request(options, (res) => {
    res.on('data', (d) => {
        console.log(d);
    });
});

Node JS (Using Fetch API)

Take note that the Fetch API was added natively into Node.Js version 18. If you're on an earlier version consider using the node-fetch NPM 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);
// Example response: {"status":"AUTHORISED","pass":true,"details":"Authorisation completed - https://license.example.com"}
if ($data->pass == true) {
    echo "License Passed";
} else {
    echo "License Failed";
    exit;
};
?>

This file has been updated to remove the V1 API options.


Suggest an edit

Review this page

FAXES

license system example

3 recommend this page