Anmelden
Loslegen

Easy Digital Downloads Dokumentation

Dokumentation, Referenzmaterialien und Tutorials für Easy Digital Downloads 

Software Licensing API – Beispiel mit Ruby

Dieses Dokument ist ein Teilsatz der
Software Licensing API-Dokumentation, die alle über die API verfügbaren Funktionen auflistet. Das Folgende ist ein Beispiel für Code, der zeigt, wie diese Funktionen mit Ruby implementiert werden.

Anfrage

require 'net/http'

uri = URI('https://domain.com/')
req = Net::HTTP::Post.new(uri)

edd_action = 'check_license' # Valid actions are activate_license, deactivate_license, get_version, check_license
license = ''
item_id = '' # The ID of the product on your store
url = 'example.org' # If you have disabled URL chaecking in the settings, you do not need this

req.set_form_data('edd_action' => edd_action, 'license' => license, 'item_id' => item_id, 'url' => url)

res = Net::HTTP.start(uri.hostname, uri.port) do |http|
http.request(req)
end

case res
when Net::HTTPSuccess, Net::HTTPRedirection
# check res.code for a 200 response, and then the response from the Software Licenseing API
# will be located in res.body as a string of JSON
puts res.body
else
res.value
end

Antwort

Eine Antwort auf die obige Anfrage wäre ein JSON-formatierter String , der etwa so aussehen würde:

{
	"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]"
}
Was this article helpful?

Verkaufen Sie noch heute!

Schließen Sie sich über 50.000 klugen Shop-Besitzern an und nutzen Sie die einfachste Methode, um digitale Produkte mit WordPress zu verkaufen.

Copyright © 2025 Sandhills Development, LLC

[universally_switcher]