Ovaj primer prikazuje kako koristiti Perl za povezivanje na naš XML-RPC server i registrovanje domena koji se plaća putem Loopia PrePaid-a. U primeru je prikazano i podešavanje domena koje sve posetioce šalje na 127.0.0.1 kako za domen, tako i za poddomene.
Imajte u vidu da, zbog jasnijeg prikaza, primer ne sadrži upravljanje greškama.
Primer
Ispod se nalazi kod za navedeni primer.
visa kodskriv ut #!/usr/bin/perl use RPC::XML; use RPC::XML::Client; use Data::Dumper; use Encode; my $global_check_domain_server_url = 'https://api.loopia.se/RPCSERV'; my $global_username = "YOUR_USERNAME"; my $global_password = "YOUR_PASSWORD"; my $client = RPC::XML::Client->new($global_check_domain_server_url); $RPC::XML::ENCODING = "UTF-8"; my $response = $client->simple_request('orderDomain', $global_username, $global_password, $domain, RPC::XML::boolean->new(1)); print "Account created: " . Dumper($response) . "\n\n"; die unless defined($response); $response = $client->simple_request('getDomain', $global_username, $global_password, $domain); print "Domain object: " . Dumper($response) . "\n\n"; my $reference_no = $response->{"reference_no"}; my $amount = $response->{"unpaid_amount"}; $response = $client->simple_request('payInvoiceUsingCredits', $global_username, $global_password, RPC::XML::string->new($reference_no)); print "Invoice $reference_no paid ($amount SEK): " . Dumper($response) . "\n\n"; $response = $client->simple_request('addSubdomain', $global_username, $global_password, $domain, "\@"); print "Subdomain added: " . Dumper($response) . "\n\n"; $response = $client->simple_request('addZoneRecord', $global_username, $global_password, $domain, "\@", { "type" => "A", "priority" => undef, "ttl" => "300", "rdata" => "127.0.0.1" }); print "Record added: " . Dumper($response) . "\n\n"; $response = $client->simple_request('addSubdomain', $global_username, $global_password, $domain, "*"); print "Subdomain added: " . Dumper($response) . "\n\n"; $response = $client->simple_request('addZoneRecord', $global_username, $global_password, $domain, "*", { type => "A", "priority" => undef, "ttl" =>"300", "rdata" => "127.0.0.1" }); print "Record added: " . Dumper($response) . "\n\n";