PicoraXMLRPC

XMLRPC client and server.

Provides a thin wrapper around the Inutio XMLRPC Library

//server
function add($a,$b){ return $a + $b; }
PicoraXMLRPC::addMethod('add','test.addition',array('int','int','int'),'Adds two numbers');
//client
list($success,$response) = PicoraXMLRPC::call('http://localhost/project/rpc','test.addition',1,1);
print $response; //2

You can define the constant "DEBUG_XMLRPC" before using PicoraXMLRPC::call() to get debugging information.

Method Overview

Return Visibility Name Parameters
unknown static public addMethod (callback $callback, string $name, array $signature, string $help)
array public call (string $url, string $method)

Method Detail

static public addMethod()

Parameter Type Name Description
callback $callback
string $name
array $signature should be an array of types starting with the return value, substr would be defined as ('string','string','int','int')
string $help

Register a new method on the XMLRPC server. This should be only be defined in the config.php file.

public call()

Parameter Type Name Description
string $url
string $method

This method is similar to calluserfunc() in that you can pass any number of arguments beyond the required two, which will then call the remote XMLRPC method.

Declared in: PicoraXMLRPC.php

class PicoraXMLRPC {
    static protected $methods = array();
    /**
     * Register a new method on the XMLRPC server. This should be only be defined in the config.php file.
     * @param callback $callback
     * @param string $name
     * @param array $signature should be an array of types starting with the return value, substr would be defined as ('string','string','int','int')
     * @param string $help
     */
    static public function addMethod($callback,$name,$signature,$help){
        self::$methods[$name] = array($callback,$signature,$help);
    }
    static public function getMethods(){
        return self::$methods;
    }
    /**
     * This method is similar to call_user_func() in that you can pass any number of arguments beyond the required two, which will then call the remote XMLRPC method.
     * @param string $url
     * @param string $method
     * @return array (bool success,mixed response)
     */
    function call($url,$method){
        $client = new IXR_Client($url);
        if(defined('DEBUG_XMLRPC'))
            $client->debug = true;
        $args = func_get_args();
        return (!call_user_func_array(array($client,'query'),array($method) + array_slice($args,1)))
            ? array(false,$client->getErrorCode().' : '.$client->getErrorMessage())
            : array(true,$client->getResponse())
        ;
    }
}