License API - Create License With Existing Product

Overview
Here you can use an existing product in your Maian Cube installation for most of the required parameters. The only additional parameters are as follows:

apiKey = API Key as defined in your settings (Validates genuine post)
product = Product ID from your cube installation
timezone = Optional timezone as supported by PHP. A different timezone may be useful for time based restrictions. If not set, defaults to settings timezone.
restrictions = Array with 3 keys (domain, mac & ip). Specify information where applicable. See below.
Example
Data must be sent in JSON format as a HTTP POST. The following example shows how to use this option. NOTE that you MUST append the 'remote=yes' query string to the cube url?

<?php
$data = array(
  'apiKey' => 'AO2CN4UJGW3PR08YIVKB',
  'product' => 8,
  'timezone' => '',
  'restrictions' => array(
    'domain' => 'example.com',
    'ip' => '',
    'mac' => ''
);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://www.example.com/cube/index.php?remote=yes');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_TIMEOUT, 120);
$r = curl_exec($ch);
curl_close($ch);

echo $r;
?>
For the restrictions, specify values that are applicable to your products value for "Allowed Server Encoding String".
Return Response - HTTP or JSON
If the API has accepted the request it will return a HTTP header (default) or JSON response, depending on your preference in the 'control/options.php' file. If a failure occurs check the API log entry in the 'logs' folder if enabled.

HTTP HEADER example:

HTTP/1.0 200 OK
License data...

or

HTTP/1.0 403 Forbidden
For JSON, the response will be a JSON array with a key called 'status' and a key called 'license' if successful. Status has one of two values, either 'OK' or 'ERR'. Example:

{
"status" : "OK"
"license" : "License data..."
}

or

{
"status" : "ERR"
}
SSL
If you are transmitting to a secure site, you may need other options in your curl code.
Log File
If you are having issues, check your log file for information. If nothing is in the log file, check your servers error log.
Additional Triggers
If you want to create other operations after the license creation has run, add your custom code to the following file:

control/api/api-lic-triggers.php

Jump to Creating License Using All Parameters