phpxmlrpc to CI xml-rpc request - El Forum - 01-27-2009
[eluser]lehi.here[/eluser]
Hi all,
I have created an xml-rpc client/server using CI xml-rpc lib and working fine. But when i try to send request from the phpxmlrpc client, it keep coming back with no data sending to the server. I guest it will be the problem of the data formating in phpxmlrpc client codes. could anyone help, please?
Thanks.
Here is the server code:
Code: class Xmlrpc_server extends Controller {
function index()
{
$config['functions']['get_auth'] = array('function' => 'Xmlrpc_server.get_auth');
$config['object'] = $this;
$this->xmlrpcs->initialize($config);
$this->xmlrpcs->serve();
}
function get_auth($request)
{
$parameters = $request->output_parameters();
//print_r($parameters);
$username = '';
$password = '';
if(isset($parameters[0]['username']) && isset($parameters[0]['password'])){
$username = $parameters[0]['username'];
$password = $parameters[0]['password'];
}
$user = array('username'=>$username, 'password'=>$password);
$userInfo = $this->check_user($user);
if($userInfo==-1){
if($username=='' && $password==''){
return $this->xmlrpc->send_error_message('321', 'No User Info Provided');
}else{
return $this->xmlrpc->send_error_message('123', 'Access Denied');
}
}else{
$response = array(
array(
'id'=>$userInfo['id'] ,
'username'=>$userInfo['username'] ,
'firstname'=>$userInfo['firstname'] ,
'lastname'=>$userInfo['lastname'] ,
'password'=>$userInfo['password'] ,
'address'=>$userInfo['address'] ,
'phone'=>$userInfo['phone'] ,
'lastmodified'=>$userInfo['lastmodified'] ,
'created'=>$userInfo['created']
),
'struct');
return $this->xmlrpc->send_response($response);
}
}
function check_user($user){
.......................
}
}
and here is my phpxmlrpc code:
Code: $request = array(
array(
// Param 0
array(
'username'=> new xmlrpcval($username , "string"),
'password'=> new xmlrpcval($password, "string")
),
'struct'
)
);
$m = new xmlrpcmsg('get_auth', $request );
$c = new xmlrpc_client("/auth_service/index.php/xmlrpc_server", "192.168.1.16", 80);
$c->setDebug(2);
$r = $c->send($m);
if (!$r->faultCode()) {
$v = $r->value();
$greeting = "Details " . $username. " is " .
htmlentities($v->scalarval()) . "<BR>";
$greeting .= "<HR>I got this value back<BR><PRE>" .
htmlentities($r->serialize()) . "</PRE><HR>\n";
} else {
$greeting = "Fault <BR>";
$greeting .= "Code: " . htmlentities($r->faultCode()) . "<BR>" .
"Reason: '" . htmlentities($r->faultString()) . "'<BR>";
}
return $greeting;
phpxmlrpc to CI xml-rpc request - El Forum - 01-28-2009
[eluser]lehi.here[/eluser]
Can anyone help, please!!!
|