So I started playing with Zend_Json_Server and was having a hard time trying to figure out how to call the server from a client. Finally I checked the JSON-RPC 2.0 spec and read a very important detail that I had not realized:
The Request is expressed as a single JSON Object
This was the key to my problem. There are 4 parameters that can be sent with each JSON-RPC 2.0 request but I was sending each as a post var which is not what Zend_Json_Server expects. It simply wants one json encoded object with all the parameters inside. The 4 available parameters are:
- jsonrpc – the version you are using; I’m using 2.0.
- method – the name of the method you want to call in the server.
- params – object of parameters your method needs. If you don’t need any, don’t send this param.
- id – an identifier (anything you want) that will be sent to and from the server for this request.
I’m using Zend_Http_Client() to make the request and here is an example:
‘jsonrpc’ => ‘2.0’,
‘method’ => ‘find’,
‘params’ => array(‘326691’),
‘id’ => ‘test’
$http = new Zend_Http_Client();