[turba] how to save a photo through the api --> rpc request

Michael Rubinsky mrubinsk at horde.org
Mon Oct 27 13:09:26 UTC 2008


Quoting roman stachura <stachrom at gmail.com>:

> Hi
>
> I wonder how can I  save binary data like a photo through a rpc  
> request under the turba api from a external server.
>
> How should I compose the $rpc_parameters_turba_import array ?

After a quick glance at the code, it doesn't look like this is  
currently possible.  The binary data will need to be encoded before it  
is sent over jsonrpc, but the _turba_import method doesn't currently  
check for this and decode it. We'll have to add support for encoded  
binary data to the import method, and a way to hint at what the  
encoding type is. How to do that in a BC way though?



>
>
> require_once 'Horde/RPC.php';
>
> $rpc_endpoint = 'http://horde.yourdomain.ch/rpc.php';
>
> $rpc_options = array(
>            'user' => 'user',
>            'pass' => 'password'
>        );
>
> $rpc_method_turba_import = 'contacts.import';
>
> $photo_binary_data =  
> file_get_contents($_FILES['object']['tmp_name']['photo']['new']);
>
> $rpc_parameters_turba_import = array(
>        array(
>                'firstname'     => $_REQUEST['object']['firstname'],
>                'lastname'     => $_REQUEST['object']['lastname' ],
>                'photo'         =>  $photo_binary_data,
>                'phototype'  => $_FILES['object']['type']['photo']['new']
>                ),
>         'addressbook' => 'admin'
>
>     );
>
>
>
>    $results_turba = Horde_RPC::request(
>    'jsonrpc',
>    $rpc_endpoint,
>    $rpc_method_turba_import,
>    $rpc_parameters_turba_import,
>    $rpc_options);
>
>
> roman
> --
> Turba mailing list - Join the hunt: http://horde.org/bounties/#turba
> Frequently Asked Questions: http://horde.org/faq/
> To unsubscribe, mail: turba-unsubscribe at lists.horde.org
>


Thanks,
mike

--
The Horde Project (www.horde.org)
mrubinsk at horde.org

"Time just hates me. That's why it made me an adult." - Josh Joplin


More information about the turba mailing list