Logg inn

Bestill domene til eksisterende konto

Dette eksemplet viser hvordan man kobler til XML-RPC-serveren vår via Perl og registrerer et domenenavn som betales med Loopia PrePAID-kreditt. Videre legges det opp domenekonfigurasjon for å sende all besøkstrafikk til 127.0.0.1 både for selve domenet og eventuelle underdomener.

Merk: Kodeksemplet nedenfor inneholder ikke noen feilbehandling, for lesbarhetens skyld.

Eksempel

Nedenfor følger koden for ovenstående eksempel.


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


Hei, trenger du hjelp?

Hverdager: 8-19 Helger: 11-15