The following is a PHP example using CURL.
This endpoint downloads the software package attached to the product.
If the license belongs to a variation and that variation has its own package, the variation package is served. Otherwise, the main product package is served.
If the request is successful, the API returns the file itself, not JSON.
Example License Package Download API Request
// The post url is your WordPress website URL where the plugin is installed
// If your WordPress installation is in a sub-folder the URL to that sub-folder
// should be used instead. Example: https://domain.ltd/my-sub-folder
$post_url = 'https://domain.ltd/';
$parameters = array(
// The API command
// The fslm_v2_api_request parameter takes one of the following values
// verify, activate, deactivate, details, extra_data, license_status, download_package
'fslm_v2_api_request' => 'download_package',
// Your API Key
// You can set your API key in the page
// License Manager > Settings > API
'fslm_api_key' => '0A9Q5OXT13in3LGjM9F3W',
// The License Key
'license_key' => 'FFFF-FFFF-FFFF-FFFF'
);
// url-ify the data for the POST
$fields_string = "";
foreach ($parameters as $key => $value) {
$fields_string .= $key . '=' . urlencode($value) . '&';
}
$fields_string = rtrim($fields_string, '&');
// Open connection
$ch = curl_init();
// Capture response headers
$response_headers = array();
// Set the url, number of POST vars, POST data
curl_setopt($ch, CURLOPT_URL, $post_url);
curl_setopt($ch, CURLOPT_POST, count($parameters));
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_HEADERFUNCTION, function ($curl, $header) use (&$response_headers) {
$length = strlen($header);
$parts = explode(':', $header, 2);
if (count($parts) < 2) {
return $length;
}
$response_headers[strtolower(trim($parts[0]))] = trim($parts[1]);
return $length;
});
// Execute post
$result = curl_exec($ch);
curl_close($ch);
// If the response is JSON, display it
$json = json_decode($result, true);
if (json_last_error() === JSON_ERROR_NONE && isset($json['result'])) {
header('Content-Type: application/json; charset=UTF-8');
echo $result;
exit;
}
// Otherwise, send the package file directly to the browser
if (isset($response_headers['content-type'])) {
header('Content-Type: ' . $response_headers['content-type']);
} else {
header('Content-Type: application/octet-stream');
}
if (isset($response_headers['content-disposition'])) {
header('Content-Disposition: ' . $response_headers['content-disposition']);
} else {
header('Content-Disposition: attachment; filename="package.bin"');
}
if (isset($response_headers['content-length'])) {
header('Content-Length: ' . $response_headers['content-length']);
}
if (isset($response_headers['x-fslm-download-version'])) {
header('X-FSLM-Download-Version: ' . $response_headers['x-fslm-download-version']);
}
if (isset($response_headers['x-fslm-download-source'])) {
header('X-FSLM-Download-Source: ' . $response_headers['x-fslm-download-source']);
}
echo $result;
exit;
Successful Response
The API returns the package file as binary output, not JSON.
Successful response headers may include:
Content-Disposition: attachment; filename="your-package.zip"
X-FSLM-Download-Version: 1.0.2
X-FSLM-Download-Source: product
Expired License Key
{
"result": "error",
"code": "550",
"message": "Expired license key"
}
No Software Package Configured For This License
{
"result": "error",
"code": "820",
"message": "No software package is configured for this license"
}
Software Package File Missing On The Server
{
"result": "error",
"code": "821",
"message": "The software package could not be found on the server"
}
Invalid License Key
{
"result": "error",
"code": "100",
"message": "Invalid license key"
}
Invalid Parameters
{
"result": "error",
"code": "600",
"message": "Invalid parameters"
}
Invalid API Key
{
"result": "error",
"code": "200",
"message": "Invalid API key"
}
An Error Has Occurred Please Retry
{
"result": "error",
"code": "000",
"message": "An error has occurred please retry"
}
