当前位置: 首页>>代码示例>>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;未经允许,请勿转载。