本文整理汇总了PHP中Zend_XmlRpc_Value::getValue方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_XmlRpc_Value::getValue方法的具体用法?PHP Zend_XmlRpc_Value::getValue怎么用?PHP Zend_XmlRpc_Value::getValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_XmlRpc_Value
的用法示例。
在下文中一共展示了Zend_XmlRpc_Value::getValue方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _parseResponse
/**
* Parse the response from a XML-RPC method call, hold the response as a Zend_XmlRpc_Value object
* The response parameter must be a valid XML string
*
* @param string $response XML string to parse
*/
protected function _parseResponse($response)
{
if (!$response) {
// The response is empty
throw new Zend_XmlRpc_Client_Exception('Received empty response');
}
// Using simple XML to parse the response
try {
$simple_xml = @new SimpleXMLElement($response);
} catch (Exception $e) {
// The response is not a valid XML
throw new Zend_XmlRpc_Client_Exception('Failed to parse response: ' . $e->getMessage(), $e->getCode());
}
// We check if this is a Fault response
if (!empty($simple_xml->fault)) {
// The fault tag exists and not empty, the request failed and returned a fault response
if (empty($simple_xml->fault->value)) {
// Invalid fault response, fault tag must contain a value tag
throw new Zend_XmlRpc_Client_Exception('Invalid fault response, FAULT tag must contain a VALUE tag');
}
// Parse the fault response into a Zend_XmlRpc_Value object
try {
$this->_response = Zend_XmlRpc_Value::getXmlRpcValue($simple_xml->fault->value, Zend_XmlRpc_Value::XML_STRING);
} catch (Zend_XmlRpc_Value_Exception $e) {
// Failed to create a Zend_XmlRpc_Value object from the fault
throw new Zend_XmlRpc_Client_Exception('Invalid fault response, ' . $e->getMessage());
}
$fault = $this->_response->getValue();
throw new Zend_XmlRpc_Client_Exception('Request failed, ' . $fault['faultString'], $fault['faultCode']);
} elseif (empty($simple_xml->params)) {
// Invalid response, no params tag
throw new Zend_XmlRpc_Client_Exception('Invalid response, method response must contain a PARAMS tag');
} elseif (empty($simple_xml->params->param)) {
// Invalid response, params tag must contain a param tag
throw new Zend_XmlRpc_Client_Exception('Invalid response, PARAMS tag must contain a PARAM tag');
} elseif (empty($simple_xml->params->param->value)) {
// Invalid response, param tag must contain a value tag
throw new Zend_XmlRpc_Client_Exception('Invalid response, PARAM tag must contain a VALUE tag');
}
// Parse the success response into a Zend_XmlRpc_Value object
$this->_response = Zend_XmlRpc_Value::getXmlRpcValue($simple_xml->params->param->value, Zend_XmlRpc_Value::XML_STRING);
return $this->__getResponse(self::RESPONSE_PHP_NATIVE);
}