Logga in

Beställ domän till befintligt konto

Detta exempel visar hur man via Perl ansluter till vår XML-RPC-server och registrerar ett domännamn som betalas med Loopia PrePAID-krediter. Vidare läggs domänkonfiguration upp för att skicka all besökstrafik till 127.0.0.1 både för domänen i sig och eventuella subdomäner.

Notera att kodexemplet nedan inte innehåller någon felhantering för läsbarhetens skull.

Exempel

Nedan följer koden för ovanstående exempel.


#!/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";


Hej, behöver du hjälp?

Vardagar: 8-19 Helger: 11-15