Chapter 11. Examples

Table of Contents

XML-RPC client: state name query
Executing a multicall call

The best examples are to be found in the sample files included with the distribution. Some are included here.

XML-RPC client: state name query

Code to get the corresponding state name from a number (1-50) from the demo server available on SourceForge


  $m = new xmlrpcmsg('examples.getStateName',
    array(new 
xmlrpcval($HTTP_POST_VARS["stateno"], "int")));
  
$c = new xmlrpc_client("/server.php""phpxmlrpc.sourceforge.net"80);
  
$r $c->send($m);
  if (!
$r->faultCode()) {
      
$v $r->value();
      print 
"State number " htmlentities($HTTP_POST_VARS["stateno"]) . " is " .
        
htmlentities($v->scalarval()) . "<BR>";
      print 
"<HR>I got this value back<BR><PRE>" .
        
htmlentities($r->serialize()) . "</PRE><HR>\n";
  } else {
      print 
"Fault <BR>";
      print 
"Code: " htmlentities($r->faultCode()) . "<BR>" .
            
"Reason: '" htmlentities($r->faultString()) . "'<BR>";
  }