FaxStore

Prerequisites
Installation & Setup
API
Config File
Developer Mode
Developer Tools
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;
};
?>

Python (using 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"))

Python (using requests)

import requests
url = "https://license.example.com/api/check/1"
querystring = {"info":"INFO_FOR_REQUEST_OPTIONAL"}
payload = ""
headers = {
    "Authorization": "LICENSE_KEY",
    "Accept": "application/json"
}
response = requests.request("POST", url, data=payload, headers=headers, params=querystring)
print(response.text)

Powershell (using web-request)

$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

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