CodeIgniter Forums
XML-RPC Server Response Nested Arrays - How to "struct" - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: XML-RPC Server Response Nested Arrays - How to "struct" (/showthread.php?tid=54448)



XML-RPC Server Response Nested Arrays - How to "struct" - El Forum - 09-09-2012

[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!