Perl 5 ExampleΒΆ

This is an example of how to use the Memset API with Perl 5 and XML::RPC::Client.

Substitute API_KEY_HEX with a valid API key.

#!/usr/bin/env perl
#
# Memset API example with Perl 5.
#

require RPC::XML;
require RPC::XML::Client;

use strict;
use warnings;

my $API_URL = 'https://API_KEY_HEX:@api.memset.com/v1/xmlrpc';

my $c = RPC::XML::Client->new($API_URL);

my $r;

# method invocation, no parameters
$r = $c->send_request('system.listMethods');
die("Error: $r") unless ref $r;

print "Method list:\n" .join("\n", @{$r->value}) ."\n\n";

# method invocation, named parameters
$r = $c->send_request('service.info', { name=>'myserver1' });
die("Error: $r") unless ref $r;

print "service.info:\n";

foreach (keys %{$r->value}) {
	print $_ ." = " .$r->value->{$_} ."\n";
}

Previous topic

node.js Example

Next topic

Go Example

This Page