Entrar
Começar

Documentação do Easy Digital Downloads

Documentação, Materiais de Referência e Tutoriais para Easy Digital Downloads 

API de Licenciamento de Software – Exemplo usando Perl

Este documento é um subconjunto do documento da API de Licenciamento de Software, que lista todos os recursos disponíveis através da API. O seguinte é um código de exemplo que demonstra como implementar esses recursos com Perl.

Solicitação

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_id = ''; # The ID of the Download on your website
my $url = 'example.org'; # If you have disabled URL checking in the settings, you do not need this value

my $api = 'https://domain.com/';

my $ua = LWP::UserAgent->new();
my $response = $ua->post( $api, { 'edd_action' => $edd_action, 'license' => $license, 'item_id' => $item_id, '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;

Resposta

Uma resposta para a consulta acima seria uma string formatada em JSON que se pareceria com isto:

{
	"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]"
}

Este artigo foi útil?

Comece a vender hoje mesmo!

Junte-se a mais de 50.000 proprietários de lojas inteligentes e comece a usar a maneira mais fácil de vender produtos digitais com o WordPress.

Copyright © 2025 Sandhills Development, LLC

[universally_switcher]