The API included with the WordPress Licensing System allows you to remotely activate license keys, check if keys are valid (and not expired), and also retrieve information about the latest versions of software.
Each of the methods below works in the same way. The website URL that you have WordPress Licensing System installed on will act as the API end point. All requests to the API are done as GET requests and follow this form:
http://YOURWPLSDOMAIN.com/?wpls_action={request type}&code={wpls product code}&license={license key}&url={url of the site being licensed}
There are six request types:
- activate – Used to remotely activate a license key for a domain url
- deactivate – Used to remotely deactivate a license key for a domain url
- check_license – Used to remotely check if a license key is activated, valid, and not expired
- get_version – Used to remotely retrieve the latest version information for a product
- get_data – Used to remotely retrieve license data
- do_upgrade – Used to get url product upgrade to other version
Activate a License Key
To activate a license remotely, the URL you will use is:
http://YOURWPLSDOMAIN.com/?wpls_action=activate&code=sample4351&license=PRO-z3FQD-6BlNe-1bUgP&url=http://mydomain.com
sample4351 will be replaced with the actual of your WPLS product unique code. This should match the code of the product in WordPress Licensing System exactly.
The license parameter is set to the license key you wish to activate.
The response for this request will be a jSon object. If the license has been successfully activated, the response will be:
{ "license_status": "valid", "item_name": "WPLS Product name", "license_type": "BASIC", "expires": "2015-01-01 00:00:00", "payment_id": 'inv-df4396cc2dea8b50125007a909b1292e', "customer_name": "John Doe", "customer_email": "[email protected]" }
If the license is invalid and failed to activate, the response will be:
{ "license_status": "invalid", "item_name": "WPLS Product name", "license_type": "BASIC", "expires": "2015-01-01 00:00:00", "payment_id": 'inv-df4396cc2dea8b50125007a909b1292e', "customer_name": "John Doe", "customer_email": "[email protected]" }
Check if a License is Valid / Active
Checking if a license is valid and not expired is very similar to activating. This request is usually done if you need to confirm that a license is still valid after it has been activated. Licenses expire after one month (by default), so this is what you will use to check if the license has expired.
To check a license status remotely, the URL you will use is:
http://YOURWPLSDOMAIN.com/?wpls_action=check_license&code=sample4351&license=PRO-z3FQD-6BlNe-1bUgP&url=http://mydomain.com
sample4351 will be replaced with the actual of your wpls product unique code. This should match the code of the product in WordPress Licensing System exactly.
The license parameter is set to the license key you wish to check.
The response for this request will be a json object. If the license is active and still valid, the response will be:
{ "license_status": "valid", "item_name": "WPLS Product name", "license_type": "BASIC", "expires": "2015-01-01 00:00:00", "payment_id": 'inv-df4396cc2dea8b50125007a909b1292e', "customer_name": "John Doe", "customer_email": "[email protected]" }
If the license is invalid and failed to activate, the response will be:
{ "license_status": "invalid", "item_name": "WPLS Product name", "license_type": "BASIC", "expires": "2015-01-01 00:00:00", "payment_id": 'inv-df4396cc2dea8b50125007a909b1292e', "customer_name": "John Doe", "customer_email": "[email protected]" }
Default data retrieved by jSon, you can retrieve by xml version by add
&data-type=xml
at the end of remote url so it should be like
http://YOURWPLSDOMAIN.com/?wpls_action=check_license&code=sample4351&license=PRO-z3FQD-6BlNe-1bUgP&url=http://mydomain.com&data-type=xml
And will give result callback
<wpls_data> <license_status>valid</license_status> <item_name>WPLS Product name</item_name> <license_type>BASIC</license_type> <expires>2015-01-01 00:00:00</expires> <payment_id>inv-df4396cc2dea8b50125007a909b1292e</payment_id> <customer_name>John Doe</customer_name> <customer_email>[email protected]</customer_email> </wpls_data>