Code Example
$curl = curl_init();
$endpoint = '{{domain}}/wp-json/wclm/v3/download-package/';
$parameters = array(
// The License Key
'license_key' => 'FFFF-FFFF-FFFF-FFFF'
);
// Capture response headers
$response_headers = array();
curl_setopt_array($curl, array(
CURLOPT_URL => $endpoint,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => $parameters,
CURLOPT_USERAGENT => $_SERVER['HTTP_USER_AGENT'],
CURLOPT_SSL_VERIFYPEER => false,
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;
},
CURLOPT_HTTPHEADER => array(
// Authenticated user token
'Authorization: Bearer {{User Token}}'
)
));
$response = curl_exec($curl);
curl_close($curl);
// If the response is JSON, display it
$json = json_decode($response, true);
if (
json_last_error() === JSON_ERROR_NONE &&
isset($json['response']) &&
isset($json['signature'])
) {
header('Content-Type: application/json; charset=UTF-8');
echo $response;
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 $response;
exit;
API Responses
Successful Response
The API returns the package file directly, 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
{
"response": {
"result": "error",
"code": "100",
"message": "Invalid license key",
"api_timestamp": "current timestamp"
},
"signature": "Signature or OpenSSL error"
}
{
"response": {
"result": "error",
"code": "550",
"message": "Expired license key",
"api_timestamp": "current timestamp"
},
"signature": "Signature or OpenSSL error"
}
{
"response": {
"result": "error",
"code": "900",
"message": "The authenticated user doesn't own this license key",
"api_timestamp": "current timestamp"
},
"signature": "Signature or OpenSSL error"
}
{
"response": {
"result": "error",
"code": "992",
"message": "No software package is configured for this license",
"api_timestamp": "current timestamp"
},
"signature": "Signature or OpenSSL error"
}
{
"response": {
"result": "error",
"code": "993",
"message": "The software package could not be found on the server",
"api_timestamp": "current timestamp"
},
"signature": "Signature or OpenSSL error"
}
WordPress’s built-in REST API responses.
{
"code": "rest_forbidden",
"message": "Sorry, you are not allowed to do that.",
"data": {
"status": 401
}
}
{
"code": "rest_forbidden",
"message": "Sorry, you are not allowed to do that.",
"data": {
"status": 403
}
}
