XML-RPC

From Elgg Documentation

Jump to: navigation, search

Elgg enables you to expose functions via XML-RPC, very much similar to the generic REST style [ElggApi API]. First, create a function which will handle data, with a single parameter since it will get passed a XMLRPCCall object:

function your_api_function(XMLRPCCall $data) {
}

Next, register your handler:

register_xmlrpc_handler($method, $handler)

`$method` is the method you want to handle (e.g. `pingback.ping`) and `$handler` is the name of your newly created handler. The response must return an XMLRPCResponse object, either a success or an error. The response object itself should get constructed out of valid XMLRPCParameter classes.An example:

$result = new XMLRPCResponse();
 
$value = "Hello there!";
 
$result->addString($value);
 
return $result;
Personal tools