[dev] Pass parameters via json RPC

Ralf Lang lang at b1-systems.de
Fri Aug 2 05:10:40 UTC 2013


On 01.08.2013 17:27, Thomas Jarosch wrote:
> Hey there,
> 
> I try to use the json RPC API of Horde.
> Here's the code derived from the (xmlrpc) RPC example code:
> 
> ----------------------------------------------------
> <?php
> /**
>  * @package Rpc
>  */
> 
> require_once '/usr/share/pear/www/horde/lib/Application.php';
> Horde_Registry::appInit('horde', array('cli' => true));
> 
> // XML-RPC endpoint
> $rpc_endpoint = 'http://localhost/horde/rpc.php';
> 
> // XML-RPC method to call
> $rpc_method = 'notes.getChangesByModSeq';
> 
> // XML-RPC options, usually username and password
> $rpc_options = array(
>     'request.username' => 'USERNAME',
>     'request.password' => 'MY_PASSWORD',
> );
> 
> $params = array('start' => '0',
>                 'end' => '100');
> 
> $http_client = new Horde_Http_Client($rpc_options);
> $result = Horde_Rpc::request(
>     'jsonrpc',
>     $GLOBALS['rpc_endpoint'],
>     $GLOBALS['rpc_method'],
>     $GLOBALS['http_client'],
>     $params);
> 
> var_dump($result);
> ----------------------------------------------------
> 
> The API call works when I hardcode the "start" and "end"
> parameters inside mnemo/lib/Api.php.
> 
> 
> What's the correct way to encode the
> "start" and "end" parameters for the RPC call?
> 
> Right now it does not recognize the parameters.
> 
> Cheers,
> Thomas
> 
http://www.ralf-lang.de/2012/02/18/distributed-applications-with-horde-4/

The parameters array is an array (not a hash) of parameters.

If you need to pass a hash, pass it as array($hash).

-- 
Ralf Lang
Linux Consultant / Developer
Tel.: +49-170-6381563
Mail: lang at b1-systems.de
B1 Systems GmbH
Osterfeldstraße 7 / 85088 Vohburg / http://www.b1-systems.de
GF: Ralph Dehner / Unternehmenssitz: Vohburg / AG: Ingolstadt,HRB 3537

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 263 bytes
Desc: OpenPGP digital signature
URL: <http://lists.horde.org/archives/dev/attachments/20130802/bc6ae409/attachment.bin>


More information about the dev mailing list