[dev] Pass parameters via json RPC

Michael J Rubinsky mrubinsk at horde.org
Thu Aug 1 16:26:12 UTC 2013


Quoting Thomas Jarosch <thomas.jarosch at intra2net.com>:

> 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.

I *think* you need to pass them as a numerically indexed array in the  
order they appear in the Api method you are calling. So, $params =  
array(0, 100);

-- 
mike

The Horde Project (www.horde.org)
mrubinsk at horde.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-keys
Size: 2200 bytes
Desc: PGP Public Key
URL: <http://lists.horde.org/archives/dev/attachments/20130801/aeb7c868/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 6062 bytes
Desc: S/MIME Signature
URL: <http://lists.horde.org/archives/dev/attachments/20130801/aeb7c868/attachment-0001.bin>


More information about the dev mailing list