merge upstream phpxmlrpc
[plcapi.git] / php / phpxmlrpc / demo / client / perl / test.pl
1 #!/usr/local/bin/perl
2
3 use Frontier::Client;
4
5 my $serverURL='http://localhost/demo/server/server.php';
6
7 # try the simplest example
8
9 my $client = Frontier::Client->new(
10     'url' => $serverURL, 'debug' => 0, 'encoding' => 'iso-8859-1'
11 );
12 my $resp = $client->call("examples.getStateName", 32);
13
14 print "Got '${resp}'\n";
15
16 # now send a mail to nobody in particular
17
18 #$resp = $client->call("mail.send", (
19 #    "edd",
20 #    "Test",
21 #    "Bonjour. Je m'appelle Gérard. Mañana. ",
22 #    "freddy",
23 #    "",
24 #    "",
25 #    'text/plain; charset="iso-8859-1"')
26 #);
27 #
28 #if ($resp->value()) {
29 #    print "Mail sent OK.\n";
30 #} else {
31 #    print "Error sending mail.\n";
32 #}
33
34 # test echoing of characters works fine
35
36 $resp = $client->call("examples.echo", 'Three "blind" mice - ' . "See 'how' they run");
37 print $resp . "\n";
38
39 # test name and age example. this exercises structs and arrays
40
41 $resp = $client->call("examples.sortByAge",
42     [
43         { 'name' => 'Dave', 'age' => 35},
44         { 'name' => 'Edd', 'age' => 45 },
45         { 'name' => 'Fred', 'age' => 23 },
46         { 'name' => 'Barney', 'age' => 36 }
47     ]
48 );
49
50 my $e;
51 foreach $e (@$resp) {
52     print $$e{'name'} . ", " . $$e{'age'} . "\n";
53 }
54
55 # test base64
56
57 $resp = $client->call("examples.decode64",
58     $client->base64("TWFyeSBoYWQgYSBsaXR0bGUgbGFtYiBTaGUgdGllZCBpdCB0byBhIHB5bG9u")
59 );
60
61 print $resp . "\n";