I am new to php5 programming :)
I redirect users to another server to login. After they login
successfully, they will be redirected to test.php. The server provides
xml_rpc interface so I can communicate with it. After running my
scripts, I get this error:
Fatal error: Call to undefined method XML_RPC_Respons e::kindOf() in /
usr/share/PEAR/XML/RPC.php on line 1972
It seems it is these two lines that cause problems:
I do get some response from the server, though.
The followings are my scripts:
test.php
<?php
error_reporting (E_ALL);
ini_set('displa y_errors', true);
include("cwl.ph p");
$test=new cwl();
$test->test();
?>
cwl.php
<?php
require 'XML/RPC.php';
error_reporting (E_ALL);
ini_set('displa y_errors', true);
class cwl{
private $cwlURL;
private $xmlrpcPath;
private $appID;
private $appIDPassword;
private $cwlClient;
private $sessionTicket;
private $params;
function __construct()
{
$this->appID='xxx';
$this->appIDPassword= 'xxx';
$this->xmlrpcPath='/path';
$this->cwlURL='someur l;
$this->sessionTicket= $_GET['ticket'];
$this->params=array ( new XML_RPC_Value($ this->sessionTicke t,
'string'));
$this->cwlClient=$thi s->getCWLClient() ;
}
private function getCWLClient()
{
$client=new XML_RPC_Client( $this->xmlrpcPath, $this->cwlURL);
$client->setCredentia ls ($this->appID, $this->appIDPassword) ;
$client->setDebug(1);
return $client;
}
protected function makeCall($funct ionName)
{
$functionName=' session.'.$func tionName;
try
{
$msg = new XML_RPC_Message ($functionName, $this->params);
$resp= new XML_RPC_Respons e(new XML_RPC_Value() );
$resp= $this->cwlClient->send($msg);
return $resp;
}
catch (Exception $e)
{
$e->__toString() ;
}
}
public function test()
{
$val =new XML_RPC_Value() ;
$val = $this->makeCall('getI dentities');
//*************** ************
//It seems it the line below causes the problem
$data = XML_RPC_decode( $val);
echo "<br>";
if (isset($data['student_number ']))
echo $data['student_number ']."<br>";
else echo "Not a student<br>";
if (isset($data['employee_numbe r']))
echo $data['employee_numbe r']."<br>";
else echo "Not an employee<br>";
}
}
?>
Any advice? Thanks,
I redirect users to another server to login. After they login
successfully, they will be redirected to test.php. The server provides
xml_rpc interface so I can communicate with it. After running my
scripts, I get this error:
Fatal error: Call to undefined method XML_RPC_Respons e::kindOf() in /
usr/share/PEAR/XML/RPC.php on line 1972
It seems it is these two lines that cause problems:
I do get some response from the server, though.
The followings are my scripts:
test.php
<?php
error_reporting (E_ALL);
ini_set('displa y_errors', true);
include("cwl.ph p");
$test=new cwl();
$test->test();
?>
cwl.php
<?php
require 'XML/RPC.php';
error_reporting (E_ALL);
ini_set('displa y_errors', true);
class cwl{
private $cwlURL;
private $xmlrpcPath;
private $appID;
private $appIDPassword;
private $cwlClient;
private $sessionTicket;
private $params;
function __construct()
{
$this->appID='xxx';
$this->appIDPassword= 'xxx';
$this->xmlrpcPath='/path';
$this->cwlURL='someur l;
$this->sessionTicket= $_GET['ticket'];
$this->params=array ( new XML_RPC_Value($ this->sessionTicke t,
'string'));
$this->cwlClient=$thi s->getCWLClient() ;
}
private function getCWLClient()
{
$client=new XML_RPC_Client( $this->xmlrpcPath, $this->cwlURL);
$client->setCredentia ls ($this->appID, $this->appIDPassword) ;
$client->setDebug(1);
return $client;
}
protected function makeCall($funct ionName)
{
$functionName=' session.'.$func tionName;
try
{
$msg = new XML_RPC_Message ($functionName, $this->params);
$resp= new XML_RPC_Respons e(new XML_RPC_Value() );
$resp= $this->cwlClient->send($msg);
return $resp;
}
catch (Exception $e)
{
$e->__toString() ;
}
}
public function test()
{
$val =new XML_RPC_Value() ;
$val = $this->makeCall('getI dentities');
//*************** ************
//It seems it the line below causes the problem
$data = XML_RPC_decode( $val);
echo "<br>";
if (isset($data['student_number ']))
echo $data['student_number ']."<br>";
else echo "Not a student<br>";
if (isset($data['employee_numbe r']))
echo $data['employee_numbe r']."<br>";
else echo "Not an employee<br>";
}
}
?>
Any advice? Thanks,
Comment