monkeypaw201 Posted September 12, 2012 Share Posted September 12, 2012 Hello, I have successfully gotten an XML-RPC server up and running (in CodeIgniter) 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: 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: $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! Quote Link to comment https://forums.phpfreaks.com/topic/268276-xml-rpc-server-response-nested-arrays-how-to-struct/ Share on other sites More sharing options...
Christian F. Posted September 12, 2012 Share Posted September 12, 2012 The problem does not reside in the code you've posted, but in the send_response () function. Or rather, its inability to deal with arrays as a part of the response data. You'll either need to find a method which properly translates the data into XML, supports sending a multi-dimensional array, or rewrite your data aggregation function to flatten it out. I recommend the first. Quote Link to comment https://forums.phpfreaks.com/topic/268276-xml-rpc-server-response-nested-arrays-how-to-struct/#findComment-1377172 Share on other sites More sharing options...
monkeypaw201 Posted September 12, 2012 Author Share Posted September 12, 2012 Thanks, I'll poke around in the send_response() and see if I can tweak the code a bit. Quote Link to comment https://forums.phpfreaks.com/topic/268276-xml-rpc-server-response-nested-arrays-how-to-struct/#findComment-1377210 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.