setDebug(1);
//More debug info, create the payload before sending.
//Not necessary to function, but useful to test
//$msg->createPayload();
//TEST Print the response to the screen for testing
//echo "
" . print_r($msg->payload, true) . "
";
//Actually have the client send the message to the server. Save response.
$resp = $cli->send($msg);
//If there was a problem sending the message, the resp will be false
if (!$resp)
{
//print the error code from the client and exit
echo 'Communication error: ' . $cli->errstr;
exit;
}
//If the response doesn't have a fault code, show the response as the array it is
if(!$resp->faultCode())
{
//Store the value of the response in a variable
$val = $resp->value();
//Decode the value, into an array.
$data = XML_RPC_decode($val);
//Optionally print the array to the screen to inspect the values
echo "" . print_r($data, true) . "
";
}else{
//If something went wrong, show the error
echo 'Fault Code: ' . $resp->faultCode() . "\n";
echo 'Fault Reason: ' . $resp->faultString() . "\n";
}
?>