My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
DocumentationForPHP  
Implementation details and usage documentation for PHP RPC implementations.
Featured
Updated Feb 4, 2010 by WestonRuter

PHP Server

This is a draft.

This server implementation is implemented as the class RPCServer; it is available in both PHP 4 and PHP 5. The class is implemented as a singleton. Since PHP 4 does not support singletons, authors using the PHP 4 version should restrict themselves to using the RPCServer class's getInstance method instead of constructing a new instance.

The key feature of the PHP implementation is that it parses the server PHP source file(s) for the parameter names and default values in the function prototypes for the public methods; this enables parameters to be passed as an associative array instead of a positional array, and furthermore the default function parameter values defined in the PHP functions may be employed instead of always supplying the 'null' default value as specified by JSON-RPC 1.1 WD (which I believe is deficient in this point).

Usage

if(!class_exists('DateTime'))
    require_once('DateTime.class.php');
require_once('RPCServer.class.php');
$server = RPCServer::getInstance(); //note that the RPCServer class is a singleton
function getTemp($zipCode){
    //...
    return $row['temperature'];
}
$server->addMethod("getTemp");
$server->processRequest(); //required in PHP4, otherwise called automatically by the destructor in PHP 5

Class Methods

  • preserveDefaultParameters(defaultParametersPreserved)
  • convertISO8601Strings(iso8601StringsConverted)
  • useIncludedFunctions(isUsingIncludedFunctions)
  • setDefaultResponseType(type)
  • setJSONDateFormat(formatName) (sets cookie)
  • setDBResultIndexType(indexType) (sets cookie)
  • setDebugMode(state)
  • addMethod(privateProcName, publicMethodName)
  • processRequest()

RPC Methods

  • system.listMethods
  • system.describe (as defined by JSON-RPC 1.1 WD)
  • system.setJSONDateFormat (envokes RPCServer::setJSONDateFormat)
  • system.setDBResultIndexType (envokes RPCServer::setDBResultIndexType)
Comment by pigip...@gmail.com, Dec 19, 2007

If I return an object instance, this implementation will add a nesting level to the JSON string.. is this correct?

for istance if I return an instance of

class A{
public $b;
}

where $b is an instance of class B

I will get a JSON string like: { A:{ b:{ B:{ ... } } } }

is this correct? Since I would prefer to obtain something like b

Comment by amarbija...@gmail.com, Mar 25, 2010

this not a clear documentation, where can i get more documentation for google xmlrpc? please help


Sign in to add a comment
Powered by Google Project Hosting