This API enable you get all information about specific license as date of creation, expire date, activation date, is active or not active duration and so on.
Request
To request to server need specific parameters are a, b, api_Key, license_key, post_token and signature. The value of ’a ‘must be ‘license’ and ‘b’ equal ‘get’.
We send this parameter as "postData" array to server.
$apiKey = '338e7963ffd9137deb18dd002b7deff9';
$apiSecret = '3dabbf055f4fb283724b6664fcd34a8c';
$apiURL = 'http://test.joudisoft.com/license-manager/www/api/v1/system/';
$licenseKey = '74382066405804';
$postData = array(
'a' => 'license',
'b' => 'get',
'api_key' => apiKey,
'license_key' => licenseKey,
'post_token' => md5(rand(1,500).time()),
);
Then sort postData descending sort.
ksort($postData);
Then concatenate all postData element and put them in signature.
foreach($postData as $key => $val) {
if((!is_string($val) && !is_numeric($val))) continue;
$signature .= $val;
}
An MD5 hash apiSecre and signature, The two values are concatenated and then hashed using the MD5 algorithm, then put MD5 result in signature and add it to postData.
$postData['signature'] = md5($apiSecret.$signature);
A-"function_exists " Function send request to server and determine property of request using curl library .
function_exists('curl_init'){
$request = curl_init($apiURL);
curl_setopt($request, CURLOPT_POST, true);
curl_setopt($request, CURLOPT_POSTFIELDS, $postData);
curl_setopt($request, CURLOPT_RETURNTRANSFER, true);
curl_setopt($request, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($request, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($request, CURLOPT_TIMEOUT, 120);
$responseData = curl_exec($request);
$responseHttpCode = curl_getinfo($request, CURLINFO_HTTP_CODE);
curl_close($request);
}
Responce
1- if request hasn’t done successfully, mean response code not equal 200 this short message will appears to you.
if(!stristr($httpHeaders[0], '200'))
echo "API Request Failed, HTTP / Error: $httpHeaders[0]";
2- If responseData is empty or not string, this message will appears to you.
echo 'API Request Failed';
3-If responseData is empty or not array or "msg" key of responseData is empty or "type" key of responseData is empty, this message will appear.
if(empty($responseData) || !is_array($responseData) || empty($responseData['msg']) || empty($responseData['type']))
echo 'Invalid Response Data Syntax';
4-If value of "type" element in responseData isn’t equal success or responseData "exception" is empty .the response is "type" and "msg" value.
if($responseData['type'] !== 'success' || empty($responseData['exception'])) {
echo ucfirst($responseData['type']) . ' : ' . $responseData['msg'];
exit();
}
5-New parameter "signature Plus" used to ensure that this responce from license server,if "signature Plus" is equal server "signaturePlus",the responce is as below.
$signaturePlus = md5($postData['signature'].$apiSecret);
if($responseData['signature_plus'] !== $signaturePlus) {
echo 'Response received, an invalid signature plus detected, message not coming from license Server';
exit();
}
6-If type of "responseData" is equal success .the output as show below.
if($responseData['type'] == 'success') {
echo "License request has been done, license data received";
echo "\r\n \r\n";
echo "Full Response Data in JSON";
echo "\r\n \r\n";
echo json_encode($responseData);
echo "\r\n \r\n";
echo "License data is always in the exception as following";
echo "\r\n \r\n";
echo json_encode($responseData['exception']);
echo "\r\n \r\n";
echo "You have to validate expiration and assert that license key have not been used at your application before if you prevent duplicate usage, or use verify_access method to determine license is new and unaccessed";
echo "\r\n \r\n";
echo "Please read license manager documentation at joudisoft.com for more information and description of every field";
echo "\r\n \r\n";
exit();
}
Output
License request has been done, license data received Full Response Data in JSON {"msg":"License request done","exception":{"period_value":1,"static":{"my_parameter_2":"MY_VALUE","my_parameter_1":"NO"},"date_expire_time":1525384676,"period_unit":"months","date_active_time":1522749476,"date_access_time":1522850497,"is_access":1,"date_expire":"2018-05-03 21:57:56","license_key":74382066405804,"date_access":"2018-04-04 14:01:37","date_create_time":1522749476,"plan_rid":71,"plan_title":"My Software Plan - 1 Month","period_seconds":2635200,"is_expired":0,"user_id":0,"date_active":"2018-04-03 09:57:56","date_create":"2018-04-03 09:57:56","is_period":1,"order_id":0,"plan_id":1,"limits":{"max_users":50,"max_orders":300,"custom_limit":50},"username":null},"type":"success","signature_plus":"c539b42e6e17b387496062a51fe7b462"} License data is always in the exception as following {"period_value":1,"static":{"my_parameter_2":"MY_VALUE","my_parameter_1":"NO"},"date_expire_time":1525384676,"period_unit":"months","date_active_time":1522749476,"date_access_time":1522850497,"is_access":1,"date_expire":"2018-05-03 21:57:56","license_key":74382066405804,"date_access":"2018-04-04 14:01:37","date_create_time":1522749476,"plan_rid":71,"plan_title":"My Software Plan - 1 Month","period_seconds":2635200,"is_expired":0,"user_id":0,"date_active":"2018-04-03 09:57:56","date_create":"2018-04-03 09:57:56","is_period":1,"order_id":0,"plan_id":1,"limits":{"max_users":50,"max_orders":300,"custom_limit":50},"username":null} You have to validate expiration and assert that license key have not been used at your application before if you prevent duplicate usage, or use verify_access method to determine license is new and unaccessed Please read license manager documentation at joudisoft.com for more information and description of every field
- msg. Tell you request has successfully done.
- exception. Have all information as which plan in ,license limits, license statistic ,how create this license, active or not ,date of creation, expire date and so on about this license.
- period_value. Value which license is active in.
- static: .
- date_expire_time. Is the period of time before license is deemed unsuitable for sale and use with second from Unix epoch.
- period_unit. Unit which use for license active duration.
- date_active_time. The time which license was activated with seconds from Unix epoch.
- date_access_time. The time which license was accessed with seconds from Unix epoch.
- is_access. This parameter is 1 or 0. 1 mean this license is access, 0 is not.
- date_expire. The date which this license will be unsuitable for use.
- license_key. The unique key for each license.
- date_access. The date which this license was accessed by user.
- date_create_time. The time which this license was created.
- plan_rid. Each plan must have RID number.
- is_expired. The value of this parameter is 1 or 0, 1 mean this license was expired. 0 mean not expired.
- user_id. User identifier for who create this license.
- date_active. The data with day, mouth, year and time when this license is active.
- date_create. The data with day, mouth, year and time when this license is create.
- b>is_period. The value of this key is 1 or 0. 1 mean this license not expired ,0 is expired.
- order_id. The order identifier is a unique number for the order which this license is sale.
- plan_id. Plan identifier which plans this license use.
- Limits.
- max_users. Max number of user use the program that use this license is 50.
- max_orders. Max number of orders in this license is 300.
- username. User who use this license.
- type. Is equal success mean API operation is successfully done .
- signature_plus.Server send "signature_plus" for validation.