Skip to main content
Easy Digital Downloads Documentation
Documentation, Reference Materials, and Tutorials for Easy Digital Downloads

Software Licensing API – Example using cURL

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

cURL is an open source command line tool and library for transferring data with URL syntax. cURL comes installed on modern versions of Mac OS X, and by default in most Linux distributions. You can test simply by typing

curl

on the command line and pressing enter. If cURL is installed you’ll see a message similar to this:

curl: try 'curl --help' or 'curl --manual' for more information

To ask cURL to make an http request for you, tell it your variables and the URL you’d like to send it to, like this:

curl
-d edd_action=check_license 
-d item_name="EDD Product Name" 
-d license=cc22c1ec86304b36883440e2e84cddff 
-d url=http://licensedsite.com 
http://YOURSITE.com/

In the above example we prefixed each variable with -d so the contents will be urlencoded. 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": "[email protected]"
}

Flags

cURL accepts many flags to change its behavior. A full tutorial of cURL is out of the scope of this document, but take a look at these flags that may interest you:

  • -u, –user USER[:PASSWORD] Server user and password
  • -A, –user-agent STRING Send User-Agent STRING to server (H)
  • -d, –data DATA HTTP POST data (H)
  • -s, –silent Silent mode (don’t output anything)
  • -o, –output FILE Write to FILE instead of stdout
  • -k, –insecure Allow connections to SSL sites without certs (H)
  • -K, –config FILE Read config from FILE

bash scripting

bash is a common Unix shell and allows for scripting actions. The following is a simple bash script that will prompt for several things and then run the cURL request and render the output to the screen.

#!/bin/bash

# This script accepts arguments for accessing the Easy Digital Downloads
# Software Licensing REST API, then runs cURL to get the results.

read -p "Item Name: " item_name;
read -p "EDD Action: " edd_action;
read -p "License: " license;
read -p "URL: " url;

exec curl --data-urlencode "item_name=$item_name" --data-urlencode "edd_action=$edd_action" --data-urlencode "license=$license" --data-urlencode "url=$url" http://YOURSITE.com/;

The above example could get changed to ask more questions, have different cURL flags, or anything you wish.