0
votes

i am using the PHP XML RPC Class from http://phpxmlrpc.sourceforge.net. I created a Client and send my method with a struct/array to the server and i got some response, but i don't have a clue how to handle the response to work with an foreach() or get the responded values directly.

Maybe some of you may help me with that?

My Code:

include("../../lib/xmlrpc.inc");
$GLOBALS['xmlrpc_internalencoding'] = 'UTF-8';
$client=new xmlrpc_client("/xmlrpc.php", "www.domain.de", 443);
$client->setDebug(0);
$auth= new xmlrpcval(
    array(
    "username" => new xmlrpcval("user"),
    "password" => new xmlrpcval('pw'),
), "struct");

$search = new xmlrpcval(
    array(
    'EMAIL'=> new xmlrpcval('[email protected]')
),'struct');

$message=new xmlrpcmsg('doProfileFindBy',
    array(
        $auth,
        new xmlrpcval(964296, "int"),
        $search

    ),'struct'
);

$r = $client->send($message, 0, 'https');
echo '<pre>';
var_dump($r);
echo '</pre>';

I do receive a response with the Data i am looking for but it is not formatted to use it as an array or so.

Hope someone can help me with that. Many thanks!

2
Could You please show us the format of the returned data (what comes out from Your var_dump)? It would be very helpful for us thus helpful for You... - shadyyx

2 Answers

0
votes

Based on Your var_dump and on the documentation to the XML RPC class http://phpxmlrpc.sourceforge.net/doc-2/ch07s04.html You should do something like this:

$r = $client->send($message, 0, 'https');
$value = $r->value();

Then regarding to http://phpxmlrpc.sourceforge.net/doc-2/ch07.html and the structure of the response You should be able to parse out the values You need. The structure of Your response is kinda complicated, containing object that has a property of array type that contains another object with array property and again and again until there is array of values You probably want to parse out...

0
votes

You can loop through the response array like this(for test) :

foreach($r as $key => $value)
{
  echo $key." : ".$value."<br>" ;
}

or as you need any specific key-value pair.