[ciapug] PHP xml-rpc parameters
Tony Bibbs
ciapug@cialug.org
Sat, 30 Apr 2005 00:27:48 -0500
I've run into this very problem before under php4 but what I did escapes
me. You may be right, the code may not be able to handle arrays of
arrays...only way to say for sure would be to pour through the RPC.php
file and check that as it loops through the array values it is checking
to see if the content is an array.
I'd start by sending over a simple single dimension array and see if
that works. Not that it would help you but PHP5's built in xml_rpc
support is quite nice.
--Tony
Dave J. Hala Jr. wrote:
> I'm trying pass some parameters to am xmlrpc procedure from a php
> client.
>
> I get the following errors:
>
> Warning: reset(): Passed variable is not an array or object in
> /usr/share/pear/XML/RPC.php on line 877
>
> Warning: Variable passed to each() is not an array or object in
> /usr/share/pear/XML/RPC.php on line 878
>
> Variable $p4 is the problem child.
>
> Here's what the php data structure for $data looks like:
> array(2) {
> [0]=>
> array(2) {
> ["ACN"]=>
> string(17) "32-46-033-1892-08"
> ["DEN"]=>
> string(1) "9"
>
> }
> [1]=>
> array(2) {
> ["ACN"]=>
> string(17) "42-56-133-2892-09"
> ["DEN"]=>
> string(4) "9"
>
> }
> }
>
> I took this data and did the following:
>
> $xml_data = XML_RPC_encode($data);
>
> Then I sent up the parameters array:
>
> # make the parameters for the procedure an array
> $p1 = new XML_RPC_Value('user','string');
> $p2 = new XML_RPC_Value('password','string');
> $p3 = new XML_RPC_Value('agency','string');
> $p4 = new XML_RPC_Value($xml_data,'array');
> $params = array($p1, $p2,$p3,$p4);
>
> # define the message that calls the procedure we want
> # parameters are username,password,data
> $message = new XML_RPC_Message('post.notifications', $params);
>
> When it makes the call I get the errors. If I remove $p4 the errors go
> away. Am I doing something wrong when passing in the array?
>
> Can I not pass parameters as array's of arrays?
>
>
> Any thoughts?
>
> :) Dave