Opprett konto og registrer domene

Dette eksemplet viser hvordan en forhandler kobler til XML-RPC-serveren vår via Perl, lager en webhotellskonto og registrerer et domenenavn.

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 $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";

 

Hei, trenger du hjelp?

Åpent hverdager 7-21, helger 11-15

 
21 49 96 00 Stengt