本文整理汇总了PHP中Value::getXmlRpcValue方法的典型用法代码示例。如果您正苦于以下问题:PHP Value::getXmlRpcValue方法的具体用法?PHP Value::getXmlRpcValue怎么用?PHP Value::getXmlRpcValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Value
的用法示例。
在下文中一共展示了Value::getXmlRpcValue方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: saveXml
/**
* Serialize fault to XML
*
* @return string
*/
public function saveXml()
{
// Create fault value
$faultStruct = array('faultCode' => $this->getCode(), 'faultString' => $this->getMessage());
$value = Value::getXmlRpcValue($faultStruct);
$generator = Value::getGenerator();
$generator->openElement('methodResponse')->openElement('fault');
$value->generateXml();
$generator->closeElement('fault')->closeElement('methodResponse');
return $generator->flush();
}
示例2: loadXml
/**
* Load a response from an XML response
*
* Attempts to load a response from an XMLRPC response, autodetecting if it
* is a fault response.
*
* @param string $response
* @return boolean True if a valid XMLRPC response, false if a fault
* response or invalid input
*/
public function loadXml($response)
{
if (!is_string($response)) {
$this->_fault = new Fault(650);
$this->_fault->setEncoding($this->getEncoding());
return false;
}
try {
$useInternalXmlErrors = libxml_use_internal_errors(true);
$xml = new \SimpleXMLElement($response);
libxml_use_internal_errors($useInternalXmlErrors);
} catch (\Exception $e) {
libxml_use_internal_errors($useInternalXmlErrors);
// Not valid XML
$this->_fault = new Fault(651);
$this->_fault->setEncoding($this->getEncoding());
return false;
}
if (!empty($xml->fault)) {
// fault response
$this->_fault = new Fault();
$this->_fault->setEncoding($this->getEncoding());
$this->_fault->loadXml($response);
return false;
}
if (empty($xml->params)) {
// Invalid response
$this->_fault = new Fault(652);
$this->_fault->setEncoding($this->getEncoding());
return false;
}
try {
if (!isset($xml->params) || !isset($xml->params->param) || !isset($xml->params->param->value)) {
throw new Exception\ValueException('Missing XML-RPC value in XML');
}
$valueXml = $xml->params->param->value->asXML();
$value = Value::getXmlRpcValue($valueXml, Value::XML_STRING);
} catch (Value\Exception $e) {
$this->_fault = new Fault(653);
$this->_fault->setEncoding($this->getEncoding());
return false;
}
$this->setReturnValue($value->getValue());
return true;
}
示例3: _getXmlRpcParams
/**
* Retrieve method parameters as XMLRPC values
*
* @return array
*/
protected function _getXmlRpcParams()
{
$params = array();
if (is_array($this->_xmlRpcParams)) {
foreach ($this->_xmlRpcParams as $param) {
$value = $param['value'];
$type = $param['type'] ?: Value::AUTO_DETECT_TYPE;
if (!$value instanceof Value) {
$value = Value::getXmlRpcValue($value, $type);
}
$params[] = $value;
}
}
return $params;
}