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


PHP Zend_Http_Response::extractMessage方法代碼示例

本文整理匯總了PHP中Zend_Http_Response::extractMessage方法的典型用法代碼示例。如果您正苦於以下問題:PHP Zend_Http_Response::extractMessage方法的具體用法?PHP Zend_Http_Response::extractMessage怎麽用?PHP Zend_Http_Response::extractMessage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Zend_Http_Response的用法示例。


在下文中一共展示了Zend_Http_Response::extractMessage方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: sendMessage

 public function sendMessage(Xcom_Xfabric_Model_Message $message, array $options = array())
 {
     $url = $this->prepareUri($message->getTopic());
     Mage::getSingleton('xcom_xfabric/debug')->start('Send Request to ' . $url->getUri(), $message->getTopic(), serialize($message->getHeaders()), isset($options['message_data']) ? $options['message_data'] : '');
     $adapter = $this->_getAdapter();
     $adapter->setConfig($this->_config);
     $adapter->write(Zend_Http_Client::POST, $url, '1.1', $this->_prepareHeaders($message->getHeaders()), $message->getBody());
     $result = $adapter->read();
     $error = '';
     $httpCode = $adapter->getInfo(CURLINFO_HTTP_CODE);
     if ($adapter->getErrno()) {
         $error = $adapter->getError();
     }
     if (!$result || $error) {
         Mage::getSingleton('xcom_xfabric/debug')->stop('Unable to complete the request.', $message->getTopic(), $result, 'Unable to complete the request. ' . $error);
         switch ($httpCode) {
             case '400':
                 $errorText = 'Bad request. ';
                 break;
             case '401':
                 $errorText = 'Request is unauthorized. ';
                 break;
             case '403':
                 $errorText = 'Request is forbidden. ';
                 break;
             case '404':
                 $errorText = 'Not Found. ';
                 break;
             case '413':
                 $errorText = 'Message is too large';
                 break;
             default:
                 $errorText = '';
                 break;
         }
         throw Mage::exception('Xcom_Xfabric', Mage::helper('xcom_xfabric')->__('Unable to complete the request. ') . $errorText . $error);
     }
     $zendHttpCode = Zend_Http_Response::extractCode($result);
     $zendHttpMessage = Zend_Http_Response::extractMessage($result);
     $zendHttpBody = Zend_Http_Response::extractBody($result);
     if ($zendHttpCode != '200') {
         Mage::getSingleton('xcom_xfabric/debug')->stop('Unable to complete the request.', $message->getTopic(), $result, $zendHttpMessage . ' ' . $zendHttpBody);
         throw Mage::exception('Xcom_Xfabric', $zendHttpMessage . ' ' . $zendHttpBody, $zendHttpCode);
     }
     if (!empty($options['synchronous']) && !$error) {
         $response = $this->_getResponseMessage($message->getCorrelationId());
         if (!$response) {
             Mage::getSingleton('xcom_xfabric/debug')->stop('Response is not received', $message->getTopic(), $result, 'No Errors');
             throw Mage::exception('Xcom_Xfabric', Mage::helper('xcom_xfabric')->__('Unable to complete the request. Please refer to the User Guide ' . 'to verify your settings and try again. If the error persists, contact your administrator.'));
         }
         return $response;
     }
     Mage::getSingleton('xcom_xfabric/debug')->stop('No Response is been waiting', $message->getTopic(), $result, $error);
     return true;
 }
開發者ID:ridhoq,項目名稱:mxpi-twitter,代碼行數:55,代碼來源:Xfabric.php

示例2: testExtractorsOnInvalidString

 public function testExtractorsOnInvalidString()
 {
     // Try with an empty string
     $response_str = '';
     $this->assertTrue(Zend_Http_Response::extractCode($response_str) === false);
     $this->assertTrue(Zend_Http_Response::extractMessage($response_str) === false);
     $this->assertTrue(Zend_Http_Response::extractVersion($response_str) === false);
     $this->assertTrue(Zend_Http_Response::extractBody($response_str) === '');
     $this->assertTrue(Zend_Http_Response::extractHeaders($response_str) === array());
 }
開發者ID:ThorstenSuckow,項目名稱:conjoon,代碼行數:10,代碼來源:ResponseTest.php

示例3: _throwResponseErrorException

 /**
  * @param Zend_Http_Response $reponse
  */
 protected function _throwResponseErrorException(Zend_Http_Response $response)
 {
     require_once 'Zend/Service/GitHub/Exception.php';
     $exceptionMessage = 'The GitHub API interaction failed. ' . '%s: %s';
     $exceptionMessage = sprintf($exceptionMessage, $response->extractCode($response->asString()), $response->extractMessage($response->asString()));
     throw new Zend_Service_GitHub_Exception($exceptionMessage);
 }
開發者ID:raphaelstolt,項目名稱:github-api-client,代碼行數:10,代碼來源:GitHub.php


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