Examples

Examples -- Usage examples for the XML_RPC package

XML-RPC client: state name query

Code to get the corresponding state name from a number (1-50) from Dave Winer's server.

require_once "XML/RPC.php";

/**
 * Get the name of state 42 (Tenesse)
 */
$params = array(new XML_RPC_Value(42, "int"));
$msg = new XML_RPC_Message("examples.getStateName", $params);

$client = new XML_RPC_Client("/RPC2", "betty.userland.com", 80);

$response = $client->send($msg);

$v = $response->value();

if (!$response->faultCode()) {
    print "State number 42 is " . $v->scalarval() . "\n";
    print "I got this value back:\n" . $response->serialize() . "\n";
} else {
    print "Fault: ";
    print "Code: " . $response->faultCode() . " Reason '" . $response->faultString() . "'\n";
}