Welcome Guest, Not a member yet? Register   Sign In
XML-RPC Server Response Nested Arrays - How to "struct"
#1

[eluser]monkeypaw201[/eluser]
Hello,

I have successfully gotten an XML-RPC server up and running with a flat array. Now I am trying to enhance it by adding nested arrays, however am running into problems.

The output I get from a client is this:

Code:
Array
(
    [start_time] => 1346601240
    [end_time] => 1346608440
    [data] => Array
)

I believe the problem is that the nested arrays are not using 'struct', but I can't be sure. The XML-RPC Server code in question:

Code:
$data = array();
  foreach($query->result() as $row)
  {
   $data[] = array(
       'valid_time_from' => $row->valid_time_from,
       'valid_time_to' => $row->valid_time_to,
       'hazard_type' => $row->hazard_type,
       'hazard_severity' => $row->hazard_severity,
       'hash' => $row->hash,
       'raw_text' => $row->raw_text,
       );
  }

  $response = array(
       array(
         'start_time' => $parameters['0'],
         'end_time' => $parameters['1'],
         'data' => $data
       ),
     'struct');

  return $this->xmlrpc->send_response($response);

Any suggestions would be much appreciated!




Theme © iAndrew 2016 - Forum software by © MyBB