Zaloguj się
Rozpocznij

Dokumentacja Easy Digital Downloads

Dokumentacja, materiały referencyjne i samouczki dla Easy Digital Downloads 

API licencjonowania oprogramowania – Przykład użycia Perla

Ten dokument jest podzbiorem dokumentu API licencjonowania oprogramowania, który zawiera listę wszystkich funkcji dostępnych za pośrednictwem API. Poniżej znajduje się przykładowy kod pokazujący, jak zaimplementować te funkcje w Perlu.

Żądanie

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;

Odpowiedź

Odpowiedzią na powyższe zapytanie będzie ciąg znaków w formacie JSON, który będzie wyglądał mniej więcej tak:

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

Czy ten artykuł był pomocny?

Zacznij sprzedawać już dziś!

Dołącz do ponad 50 000 sprytnych właścicieli sklepów i zacznij korzystać z najłatwiejszego sposobu sprzedaży produktów cyfrowych za pomocą WordPress.

Copyright © 2025 Sandhills Development, LLC

[universally_switcher]