require_once 'XML/RPC.php';
/*
* Get info about the most recently released PEAR package
*/
$params = array(new XML_RPC_Value(1, 'int'));
$msg = new XML_RPC_Message('release.getRecent', $params);
$cli = new XML_RPC_Client('/xmlrpc.php', 'pear.php.net');
// If you want to turn debugging on...
// $cli->setDebug(1);
// If your payload requires extra lines to stay in tact...
// NOTE: The $remove_extra_lines property was added in Version 1.4.6.
// $cli->remove_extra_lines = false;
// If inspect the XML request sent to the server...
// $msg->createPayload();
// logit($msg->payload); // Hypothetical function.
$resp = $cli->send($msg);
if (!$resp) {
echo 'Communication error: ' . $cli->errstr;
exit;
}
if (!$resp->faultCode()) {
$val = $resp->value();
$data = XML_RPC_decode($val);
echo $data[0]['name'] . ' is at version ' . $data[0]['version'];
} else {
/*
* Display problems that have been gracefully cought and
* reported by the xmlrpc.php script
*/
echo 'Fault Code: ' . $resp->faultCode() . "\n";
echo 'Fault Reason: ' . $resp->faultString() . "\n";
}
// To inspect the XML response from the server...
// NOTE: The $response_payload property was added in Version 1.4.6.
// logit($msg->response_payload); // Hypothetical function.
require_once 'XML/RPC.php';
$data = fetch_row_from_db(); // Hypothetical example.
$params = array(XML_RPC_encode($data));
$msg = new XML_RPC_Message('some_function_name', $params);
$cli = new XML_RPC_Client('/xmlrpc.php', 'pear.php.net');
$resp = $cli->send($msg);
// Process the same way as the other examples...