Software Licensing API - Example using Python

This document is a subset of the Software Licensing API document which lists all features available via the API. The following is example code showcasing how to implement those features with Perl.

Request

import httplib, urllib

params = urllib.urlencode({
    'edd_action' : 'activate_license', # Valid actions are activate_license, deactivate_license, get_version, check_license
    'license' : '<license key>',
    'item_name' : '<item name>',
    'url' : 'domain.com' # If you have disabled URL chaecking in the settings, you do not need this
    })

headers = {"Content-type": "application/x-www-form-urlencoded", "Accept": "text/plain"}
conn = httplib.HTTPConnection("domain.com:80") # You can use 80 (http) or 443 (https)
conn.request("POST", "/edd-sl", params, headers) # /edd-sl is the software licensing api endpoint
response = conn.getresponse()
# You should check response.status for a `200` before proceeding with parsing the data for
# a Software Licensing response
slData = response.read()
# slData now contains a string in JSON format, to handle with however prefer
print slData
conn.close()

Response

A response to the above query would be a JSON formatted string that would look something like this:

{
	"license": "valid",
	"item_name": "EDD Product name",
	"expires": "2014-10-23 00:00:00",
	"payment_id": 54224,
	"customer_name": "John Doe",
	"customer_email": "john@sample.com"
}