本文整理汇总了PHP中XML_RPC_Message::serialize方法的典型用法代码示例。如果您正苦于以下问题:PHP XML_RPC_Message::serialize方法的具体用法?PHP XML_RPC_Message::serialize怎么用?PHP XML_RPC_Message::serialize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XML_RPC_Message
的用法示例。
在下文中一共展示了XML_RPC_Message::serialize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: callMethod
/**
* XMLRPC methods wrapper
* Encode XMLRPC request message, send it, receive and decode response.
*
* @param method string, method name
* @param gettedPars array, returned by func_get_args() in called method
*
* @return array, PHP hash with response
*/
public function callMethod($method, $gettedPars)
{
$parr = array();
$XML_RPC_val = new XML_RPC_Value();
foreach ($this->mdefs[$method]['p'] as $i => $p) {
$parr[$p] = new XML_RPC_Value();
if ($this->mdefs[$method]['t'][$i] == 'array') {
$parr[$p] = XML_RPC_encode($gettedPars[$i]);
} else {
$parr[$p]->addScalar($gettedPars[$i], $this->mdefs[$method]['t'][$i]);
}
}
$XML_RPC_val->addStruct($parr);
$fullmethod = $this->mdefs[$method]['m'];
$msg = new XML_RPC_Message($fullmethod, array($XML_RPC_val));
if ($this->verbose) {
echo "parr:\n";
var_dump($parr);
echo "message:\n";
echo $msg->serialize() . "\n";
}
$this->client->setDebug($this->debug);
$res = $this->client->send($msg);
if (!$res) {
return $this->client->errstr;
}
if ($res->faultCode() > 0) {
return PEAR::raiseError("XR_CcClient::{$method}:" . $res->faultString() . " " . $res->faultCode() . "\n", $res->faultCode(), PEAR_ERROR_RETURN);
}
if ($this->verbose) {
echo "result:\n";
echo $res->serialize();
}
$val = $res->value();
$resp = XML_RPC_decode($res->value());
return $resp;
}
示例2: Request
/**
* Send request to server
*
* @access private
* @param string $command Commend
* @param object $params PEAR Params object
*/
private function Request($command, $params, $ignorerewrite = false)
{
$msg = new XML_RPC_Message($command, $params);
$cache = $this->CacheGet($msg->serialize(), $ignorerewrite);
if (!$cache)
{
$this->RPClient->setDebug(0);
$response = $this->RPClient->send($msg);
if (!$response || !$response->faultCode())
{
try
{
$val = $response->value();
$retval = XML_RPC_decode($val);
$this->CachePut($msg->serialize(), $retval);
}
catch(Exception $e)
{
return false;
}
return $retval;
}
else
{
/*
* Display problems that have been gracefully cought and
* reported by the xmlrpc.php script
*/
throw new Exception(_("RPC Fail")."(".$response->faultCode().") ".$response->faultString());
}
}
else
return $cache;
}