Skip to Content
Menu
This question has been flagged
1 Reply
10411 Views

Hello all,

I try to get "read" working thru xmlrpc with PHP but the only response I get is this kind of stuff  (PHP print_r):

xmlrpcresp Object ( [val] => xmlrpcval Object ( [me] => Array ( [struct] => Array ( [id] => xmlrpcval Object ( [me] => Array ( [string] => 0 ) [mytype] => 1 [_php_class] => ) ) ) [mytype] => 3 [_php_class] => ) [valtyp] => xmlrpcvals [errno] => 0 [errstr] => [payload] => [hdrs] => Array ( [content-type] => text/xml [content-length] => 196 [server] => Werkzeug/0.8.3 Python/2.7.3 [date] => Sat, 05 Jul 2014 16:25:04 GMT ) [_cookies] => Array ( ) [content_type] => text/xml [raw_data] => HTTP/1.0 200 OK Content-Type: text/xml Content-Length: 196 Server: Werkzeug/0.8.3 Python/2.7.3 Date: Sat, 05 Jul 2014 16:25:04 GMT id 0 )

Response is empty (I mean, does not return fields)

For now I managed to login + search or create methods.

Does somebody have a short example for read method that works ?

Thank You

Avatar
Discard

Hello, try this $msg = new xmlrpcmsg('execute'); $msg->addParam(new xmlrpcval($dbname, "string")); $msg->addParam(new xmlrpcval($userId, "int")); $msg->addParam(new xmlrpcval($password, "string")); $msg->addParam(new xmlrpcval($relation, "string")); $msg->addParam(new xmlrpcval("read", "string")); $msg->addParam(new xmlrpcval($id, "array")); $msg->addParam(new xmlrpcval($fields, "array")); With fields are array of fields you want

And when you try the response is this? It must have a mistake.The good response is something like an array of struct or an array of array i don t remember exactly. With id is the key and the struct is make of field1=value1 field2=value2 etc

Author

Yes response is the one above. But this is an array of arrays . The "struct" one is already on first line but it does not contain the fields I read ("name")

$partner_id = "10"; $id_list = array(new xmlrpcval($partner_id, "int")); $key = array( new xmlrpcval("name", "string"), ); $msg = new xmlrpcmsg('execute'); $msg->addParam(new xmlrpcval($dbname, "string")); $msg->addParam(new xmlrpcval($uid, "int")); $msg->addParam(new xmlrpcval($password, "string")); $msg->addParam(new xmlrpcval("res.partner", "string")); $msg->addParam(new xmlrpcval("read", "string")); $msg->addParam(new xmlrpcval($id_list, "array")); $msg->addParam(new xmlrpcval($key, "array"));

Best Answer

For me: 

        $val = $res->value()->scalarval();
            
            $ides = array();
            $client = new xmlrpc_client($serverUri.'object');
            $ides[0]=new xmlrpcval(1, "int"); 
            $fields = array(new xmlrpcval("name", "string"), new xmlrpcval("email", "string"));
            
            $msg = new xmlrpcmsg('execute');
            $msg->addParam(new xmlrpcval($db, "string"));
            $msg->addParam(new xmlrpcval($id, "int"));
            $msg->addParam(new xmlrpcval($password, "string"));
            $msg->addParam(new xmlrpcval("res.partner","string"));
            $msg->addParam(new xmlrpcval("read", "string"));
            $msg->addParam(new xmlrpcval($ides, "array"));
            $msg->addParam(new xmlrpcval($fields, "array"));

            $res = &$client->send($msg);

$res give : 

xmlrpcresp Object ( [val] => xmlrpcval Object ( [me] => Array ( [array] => Array ( [0] => xmlrpcval Object ( [me] => Array ( [struct] => Array ( [id] => xmlrpcval Object ( [me] => Array ( [int] => 1 ) [mytype] => 1 [_php_class] => ) [name] => xmlrpcval Object ( [me] => Array ( [string] => Delphine Lemire ) [mytype] => 1 [_php_class] => ) [email] => xmlrpcval Object ( [me] => Array ( [string] => delphine.lemire@gmail.com ) [mytype] => 1 [_php_class] => ) ) ) [mytype] => 3 [_php_class] => ) ) ) [mytype] => 2 [_php_class] => ) [valtyp] => phpvals [errno] => 0 [errstr] => [hdrs] => Array ( [content-type] => text/xml [content-length] => 416 [server] => Werkzeug/0.9.4 Python/2.7.6 [date] => Tue, 08 Jul 2014 08:18:01 GMT ) [_cookies] => Array ( ) [content_type] => text/xml )

 

Avatar
Discard
Author

Oh sorry Delphine, You were right. My fault. I had to write "array" instead of "struct". Thanks a lot for your help ;o)

Related Posts Replies Views Activity
1
Sep 20
4809
0
Mar 15
5505
1
Mar 15
7464
1
Mar 15
5362
0
Oct 24
1007