| XML-RPC for PHP: version 1.0b9 | ||
|---|---|---|
| Prev | ||
The best examples are to be found in the sample files included with the distribution. Some are included here.
Code to get the corresponding state name from a number (1-50) from Dave Winer's server
$f=new xmlrpcmsg('examples.getStateName',
array(new xmlrpcval($HTTP_POST_VARS["stateno"], "int")));
$c=new xmlrpc_client("/RPC2", "betty.userland.com", 80);
$r=$c->send($f);
$v=$r->value();
if (!$r->faultCode()) {
print "State number ". $HTTP_POST_VARS["stateno"] . " is " .
$v->scalarval() . "<BR>";
print "<HR>I got this value back<BR><PRE>" .
htmlentities($r->serialize()). "</PRE><HR>\n";
} else {
print "Fault: ";
print "Code: " . $r->faultCode() .
" Reason '" .$r->faultString()."'<BR>";
}