Writing Servers.
Building a sever is really easy with the classes provided by useful inc, you have to create a server by
instantiating a constructor this way:
instantiating a constructor this way:
<?php
$s
=new xmlrpc_server( array("examples.myFunc" =>
array("function" => "foo")));
?>
What you pass to the constructor is an asociative array of asociative arrays. The array have as keys the name
of the methods to implement, each method has as key an array indicating with key “function” the name of a
function to call for the method. In the example the procedure “examples.myFunc” calls function “foo”, foo
will be called a method handler for this reason.
of the methods to implement, each method has as key an array indicating with key “function” the name of a
function to call for the method. In the example the procedure “examples.myFunc” calls function “foo”, foo
will be called a method handler for this reason.
Writing method handlers.
A method handler is easy this is a skeleton:
<?php
function foo ($params)
{
global $xmlrpcerruser; // import user errcode value
// $params is an Array of xmlrpcval objects
if ($err)
{
// this is an error condition
return new xmlrpcresp(0, $xmlrpcerruser+1, // user error 1
"There's a problem, Captain");
}
else {
// this is a successful value being returned
return new xmlrpcresp(new xmlrpcval("All's fine!", "string"));
}
}
?>
As you can see you just check for errors and return an error (starting from $xmlrpcerruser+1) or a xmlrpcresp
if everything went ok, all the rest of the wor is done by the class.
if everything went ok, all the rest of the wor is done by the class.