當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Zend_XmlRpc_Value::getValue方法代碼示例

本文整理匯總了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);
 }
開發者ID:jorgenils,項目名稱:zend-framework,代碼行數:49,代碼來源:Client.php


注:本文中的Zend_XmlRpc_Value::getValue方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。