2 <head><title>xmlrpc - Getstatename demo</title></head>
4 <h1>Getstatename demo</h1>
6 <h2>Send a U.S. state number to the server and get back the state name</h2>
8 <h3>The code demonstrates usage of the php_xmlrpc_encode function</h3>
11 include_once __DIR__ . "/../../src/Autoloader.php";
12 PhpXmlRpc\Autoloader::register();
14 if (isset($_POST["stateno"]) && $_POST["stateno"] != "") {
15 $stateNo = (integer)$_POST["stateno"];
16 $encoder = new PhpXmlRpc\Encoder();
17 $req = new PhpXmlRpc\Request('examples.getStateName',
18 array($encoder->encode($stateNo))
20 print "Sending the following request:<pre>\n\n" . htmlentities($req->serialize()) . "\n\n</pre>Debug info of server data follows...\n\n";
21 $client = new PhpXmlRpc\Client("http://phpxmlrpc.sourceforge.net/server.php");
23 $r = $client->send($req);
24 if (!$r->faultCode()) {
26 print "<br/>State number <b>" . $stateNo . "</b> is <b>"
27 . htmlspecialchars($v->scalarval()) . "</b><br/>";
28 // print "<HR>I got this value back<BR><PRE>" .
29 // htmlentities($r->serialize()). "</PRE><HR>\n";
31 print "An error occurred: ";
32 print "Code: " . htmlspecialchars($r->faultCode())
33 . " Reason: '" . htmlspecialchars($r->faultString()) . "'</pre><br/>";
39 print "<form action=\"client.php\" method=\"POST\">
40 <input name=\"stateno\" value=\"" . $stateNo . "\"><input type=\"submit\" value=\"go\" name=\"submit\"></form>
41 <p>Enter a state number to query its name</p>";