Prijavljivanje

Kreiranje naloga i registracija domena

Ovaj primer prikazuje kako se distributer, koristeći Perl, povezuje na naš XML-RPC server, kreira hosting nalog i registruje domen.

Imajte u vidu da, zbog jasnijeg prikaza, primer ne sadrži upravljanje greškama.

Primer

Ispod se nalazi kod za navedeni primer.

 
#!/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 $contact = {	"firstname" => "Anders",
   "lastname" => "Andersson",
   "company" => "Loopia AB",
   "street" => "Kopparbergsvägen 8",
   "street2" => "",
   "zip" => "722 13",
   "city" => "Västerås",
   "country_iso2" => "se",
   "orgno" => "556633-9304",
   "phone" => "021-128222",
   "cell" => "",
   "fax" => "",
   "email" => "info\@loopia.se" };

foreach my $key (keys %$contact) {
	Encode::from_to($contact->{$key}, 'UTF-8', 'UTF-8');
}

my $domain = "anderstestarapi" . `date +%s | tr -d "\n"` . ".se";

my $response = 
   $client->simple_request('createNewAccount', $global_username,
   $global_password, $domain, $contact, RPC::XML::boolean->new(0),
   RPC::XML::boolean->new(0), RPC::XML::boolean->new(1),
   'HOSTING_UNIX', 'HOSTING_BUSINESS', RPC::XML::boolean->new(1));

print "Account created: " . Dumper($response) . "\n\n";