Software Licensing API – Example using Perl
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
use strict; use warnings; use LWP::UserAgent; use CGI; my $edd_action = 'check_license'; # Valid actions are activate_license, deactivate_license, get_version, check_license my $license = ''; my $item_name = ''; my $url = 'example.org'; # If you have disabled URL checking in the settings, you do not need this value my $api = 'http://domain.com/'; my $ua = LWP::UserAgent->new(); my $response = $ua->post( $api, { 'edd_action' => $edd_action, 'license' => $license, 'item_name' => $item_name, 'url' => $url } ); my $content = $response->decoded_content(); my $cgi = CGI->new(); # This prints the resposne from the API, you'll need to validate the data from there using the # HTTP status headers and the `success` response from the API print $content;
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": "[email protected]" }