XML-RPC - more than one record return help |
[eluser]PhxVyper[/eluser]
I have an xml-rpc server i'm creating and I need to return a response that contains more than one record. Example, 2 records I want returned: nickname = howdie ho! userid = 99 url = http://yoursite.com email = [email protected] lastname = Smith firstname = John and nickname = howdie ho 2! userid = 101 url = http://dev.yoursite.com email = [email protected] lastname = Jones firstname = James I've tried a number of different methods of building the $response structure that gets passed into send_response(), but none of them work! Any help would be appreciated. Chad
[eluser]PhxVyper[/eluser]
Wow! Is nobody else using the CodeIgniter XML-RPC server implementation?
[eluser]gtech[/eluser]
As nobody else wanted to reply I had a go, I have never used it before but wrote a test app for you. quote from the documentation: "Responses, however, usually contain multiple pieces of information. In order to accomplish this we must put the response into its own array so that the primary array continues to contain a single piece of data" here is and example that returns an array of arrays (or a struct of structs in XML speak) its copied from the documentation pages and mucked around with a little bit. You can see res1 and res2 returned in the response (you obviously need to adapt that to your data). you should be able to cut and copy the code and run the controller yourself by browsing to the index page. test.php Code: class Test extends Controller { The result: Code: Array
[eluser]gtech[/eluser]
just edited above post to implement associative arrays
[eluser]ejangi[/eluser]
I am working on an API at the moment and I want to be able to grab records from a model and throw the (easily) to the client. I put together this method (for my controller), you can throw any value at it and it will convert it to the value the xmlrpc: ![]() Code: class Api_controller extends Controller { As you can see all the magic happens in convert_to_xmlrpc_values(). Hope this helps someone!
[eluser]gtech[/eluser]
That looks like a neat little function, I will give it a go thanks.
[eluser]omed habib[/eluser]
What if you wanted to SEND an associative array to the server?
[eluser]gtech[/eluser]
[url="http://ellislab.com/forums/viewthread/81915/"]send associative array through XMLRPC example here[/url] |
Welcome Guest, Not a member yet? Register Sign In |