Add 'php/phpxmlrpc/' from commit 'cd5dbb4a511e7a616a61187a5de1a611a9748cbd'
[plcapi.git] / php / phpxmlrpc / extras / test.pl
diff --git a/php/phpxmlrpc/extras/test.pl b/php/phpxmlrpc/extras/test.pl
new file mode 100644 (file)
index 0000000..6b3cec0
--- /dev/null
@@ -0,0 +1,52 @@
+#!/usr/local/bin/perl\r
+\r
+use Frontier::Client;\r
+\r
+my $serverURL='http://phpxmlrpc.sourceforge.net/server.php';\r
+\r
+# try the simplest example\r
+\r
+my $client = Frontier::Client->new( 'url' => $serverURL,\r
+               'debug' => 0, 'encoding' => 'iso-8859-1' );\r
+my $resp = $client->call("examples.getStateName", 32);\r
+\r
+print "Got '${resp}'\n";\r
+\r
+# now send a mail to nobody in particular\r
+\r
+$resp = $client->call("mail.send", ("edd", "Test",  \r
+       "Bonjour. Je m'appelle Gérard. Mañana. ", "freddy", "", "", \r
+       'text/plain; charset="iso-8859-1"'));\r
+\r
+if ($resp->value()) {\r
+       print "Mail sent OK.\n";\r
+} else {\r
+       print "Error sending mail.\n";\r
+}\r
+\r
+# test echoing of characters works fine\r
+\r
+$resp = $client->call("examples.echo", 'Three "blind" mice - ' . \r
+       "See 'how' they run");\r
+print $resp . "\n";\r
+\r
+# test name and age example. this exercises structs and arrays \r
+\r
+$resp = $client->call("examples.sortByAge", \r
+                                                                                       [ { 'name' => 'Dave', 'age' => 35},\r
+                                                                                               { 'name' => 'Edd', 'age' => 45 },\r
+                                                                                               { 'name' => 'Fred', 'age' => 23 },\r
+                                                                                               { 'name' => 'Barney', 'age' => 36 } ] );\r
+\r
+my $e;\r
+foreach $e (@$resp) {\r
+       print $$e{'name'} . ", " . $$e{'age'} . "\n";\r
+}\r
+\r
+# test base64\r
+\r
+$resp = $client->call("examples.decode64", \r
+                                                                                       $client->base64("TWFyeSBoYWQgYSBsaXR0bGUgbGFtYiBTaGUgd" .\r
+                                                                                                                                                       "GllZCBpdCB0byBhIHB5bG9u"));\r
+\r
+print $resp . "\n";\r