当前位置: 首页>>代码示例>>PHP>>正文


PHP Zend_Http_Response::getStatus方法代码示例

本文整理汇总了PHP中Zend_Http_Response::getStatus方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Http_Response::getStatus方法的具体用法?PHP Zend_Http_Response::getStatus怎么用?PHP Zend_Http_Response::getStatus使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend_Http_Response的用法示例。


在下文中一共展示了Zend_Http_Response::getStatus方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: parseZendResponse

 /**
  * @param Zend_Http_Response $response
  * @return json string
  * @throws
  */
 public function parseZendResponse(Zend_Http_Response $response)
 {
     if ($response->getStatus() == 200) {
         return $response->getBody();
     } else {
         throw new Exception("Error: Status is: " . $response->getStatus() . " message: " . $response->getMessage());
     }
 }
开发者ID:rwadegaonkar,项目名称:hobbyhorse,代码行数:13,代码来源:Wrapper.php

示例2: __construct

 /**
  *
  *
  * @param Zend_Http_Response $response JSON response from the PinPayments gateway
  * @throws Dwyera_Pinpay_Model_ResponseParseException If an invalid JSON response object is passed
  */
 public function __construct(Zend_Http_Response $response)
 {
     $this->response = $response;
     $this->httpResponseCode = $response->getStatus();
     $this->msgObj = json_decode($response->getBody());
     if ($this->msgObj == null) {
         throw new Dwyera_Pinpay_Model_ResponseParseException("Could not parse PinPayments gateway response");
     }
 }
开发者ID:andrew-dwyer,项目名称:PINpayments,代码行数:15,代码来源:Result.php

示例3: sendRequest

 /**
  * Sends a request and returns a response
  *
  * @param CartRecover_Request $request
  * @return Cart_Recover_Response
  */
 public function sendRequest(CartRecover_Request $request)
 {
     $this->client->setUri($request->getUri());
     $this->client->setParameterGet($request->getParams());
     $this->client->setMethod($request->getMethod());
     $this->client->setHeaders('Accept', 'application/json');
     $this->response = $this->client->request();
     if ($this->response->getHeader('Content-Type') != 'application/json') {
         throw new CartRecover_Exception_UnexpectedValueException("Unknown response format.");
     }
     $body = json_decode($this->response->getBody(), true);
     $response = new CartRecover_Response();
     $response->setRawResponse($this->response->asString());
     $response->setBody($body);
     $response->setHeaders($this->response->getHeaders());
     $response->setStatus($this->response->getMessage(), $this->response->getStatus());
     return $response;
 }
开发者ID:digital-canvas,项目名称:cart-recover-phpapi,代码行数:24,代码来源:Zend.php

示例4: processInputData

 /**
  * (non-PHPdoc)
  * @see Tid_Rest_Processor_Input_Abstract::processInputData()
  */
 public function processInputData(Zend_Http_Response $response = null)
 {
     try {
         return isset($response) ? Zend_Json::decode($response->getBody()) : array();
     } catch (Exception $e) {
         $this->getRestService()->log("Error parsing JSON response: " . $e->getMessage(), Zend_Log::ERR);
         $this->getRestService()->log($e, Zend_Log::ERR);
         throw new App_Rest_Processor_Input_Exception('Error response: [code] ' . $response->getStatus() . ' [error] ' . $response->getMessage());
     }
 }
开发者ID:SandeepUmredkar,项目名称:PortalSMIP,代码行数:14,代码来源:Json.php

示例5: _parseResponse

 /**
  * Retrieve latitude and longitude from the API response
  *
  * @param Zend_Http_Response|boolean $response
  * @return array|boolean
  */
 protected function _parseResponse($response)
 {
     if ($response->isSuccessful() && $response->getStatus() == 200) {
         $_response = json_decode($response->getBody());
         $_coordinates = $_response->results[0]->geometry->location;
         $geo = array('lat' => $_coordinates->lat, 'lng' => $_coordinates->lng);
         return $geo;
     }
     return false;
 }
开发者ID:kalburgimanjunath,项目名称:magento-dealers,代码行数:16,代码来源:Google.php

示例6: listComments

 /**
  * @param $ticketId
  * @return array|mixed
  */
 public function listComments($ticketId)
 {
     try {
         $this->init()->setMethod('desk/comments')->addFilter('ticket', $ticketId)->doRequest();
     } catch (Exception $e) {
         Mage::logException($e);
     }
     if ($this->result->getStatus() == 200) {
         return json_decode($this->result->getBody());
     }
     return array();
 }
开发者ID:eltrino,项目名称:DiamanteDeskMagentoExtension,代码行数:16,代码来源:Api.php

示例7: processResponse

 public function processResponse(Zend_Http_Response $response)
 {
     $serviceName = $this->getRestService()->getServiceName();
     if (!$serviceName) {
         throw new \Application\Exceptions\UnexpectedException("Service Name doesn't exist");
     }
     $this->checkAlarmTimeSpent($serviceName);
     if ($response->isSuccessful()) {
         App::alarm()->notifyInvalidHttpCode($serviceName);
     } else {
         App::alarm()->notifyInvalidHttpCode($serviceName, $response->getStatus());
     }
 }
开发者ID:SandeepUmredkar,项目名称:PortalSMIP,代码行数:13,代码来源:Alarm.php

示例8: makeCustomerContactRequest

 /**
  * Makes a request to Recensus to contact a customer who has made a recent 
  * purchase with a merchant. An email will be sent to the customer asking 
  * them to review the product. Note: The email is not sent immediatley,
  * Recensus will determine the interval.
  * 
  *  
  */
 public function makeCustomerContactRequest($data)
 {
     $url = $this->baseUrl . str_replace('{merchantId}', $this->merchantId, $this->endpoints['ccr']);
     $this->makeRequest($url, 'POST', $data);
     if ($this->wasSuccess()) {
         return $this->parseResponse();
     } else {
         $code = $this->lastResponse->getStatus();
         $body = $this->lastResponse->getBody();
         $errorStr = $code . ': ' . $body;
         $this->handleError($errorStr);
     }
     return false;
 }
开发者ID:recensus,项目名称:php-sdk,代码行数:22,代码来源:Api.php

示例9: _parseResponse

 /**
  * Retrieve latitude and longitude from the API response
  *
  * @param Zend_Http_Response|boolean $response
  * @return array|boolean
  */
 protected function _parseResponse($response)
 {
     if ($response->isSuccessful() && $response->getStatus() == 200) {
         $_response = json_decode($response->getBody());
         if (is_array($_response->postalcodes)) {
             $_response = array_shift($_response->postalcodes);
         }
         if ($_response) {
             $geo = array('lat' => $_response->lat, 'lng' => $_response->lng);
         } else {
             $geo = false;
         }
         return $geo;
     }
     return false;
 }
开发者ID:kalburgimanjunath,项目名称:magento-dealers,代码行数:22,代码来源:Geonames.php

示例10: _processProtoMessage

 protected function _processProtoMessage(Zend_Http_Response $response = null)
 {
     if (isset($this->getRestMethod()->inputProtoMessageClass) && substr((string) $response->getStatus(), 0, 1) == '2') {
         $protoMessageClass = $this->getRestMethod()->inputProtoMessageClass;
         try {
             $response = new $protoMessageClass($response->getBody());
             return $response;
         } catch (Exception $e) {
             $this->getRestService()->log("Error loading proto message class: " . $protoMessageClass, Zend_Log::ERR);
             $this->getRestService()->log($e, Zend_Log::ERR);
             throw $e;
         }
     }
     //Errors which are taking place on input processing phase should throw
     //this Exception Subclass
     throw new App_Rest_Processor_Input_Exception('Error response: [code] ' . $response->getStatus() . ' [error] ' . $response->getMessage());
 }
开发者ID:SandeepUmredkar,项目名称:PortalSMIP,代码行数:17,代码来源:ProtoBufferEricsson.php

示例11: returnClientErrorResponse

 /**
  * Return the response data for client errors - 4XX range errors.
  * @param  Zend_Http_Response $response
  * @return array
  */
 public function returnClientErrorResponse(Zend_Http_Response $response)
 {
     $status = $response->getStatus();
     switch ($status) {
         case 401:
             $message = self::INVALID_API_KEY;
             break;
         case 403:
             $message = self::INVALID_STORE_ID;
             break;
         case 408:
             $message = self::NETWORK_TIMEOUT;
             break;
         default:
             $message = self::UNKNOWN_FAILURE;
             break;
     }
     return array('message' => Mage::helper('eb2ccore')->__($message), 'success' => false);
 }
开发者ID:sirishreddyg,项目名称:magento-retail-order-management,代码行数:24,代码来源:Validator.php

示例12: parseRawResponse

 /**
  * Extract the API response data from the given HTTP response object.
  *
  * @param Zend_Http_Response $response
  *
  * @return $this
  */
 protected function parseRawResponse(Zend_Http_Response $response)
 {
     if ($response->isSuccessful()) {
         $content = $response->getBody();
         if (strlen($content) > 0) {
             try {
                 $xml = simplexml_load_string($response->getBody());
             } catch (Exception $e) {
                 // Failed to parse XML
                 $this->successful = false;
                 $this->setMessage("Failed to parse a response from Klevu.");
                 Mage::helper('klevu_search')->log(Zend_Log::ERR, sprintf("Failed to parse XML response: %s", $e->getMessage()));
                 return $this;
             }
             $this->xml = $xml;
             $this->successful = true;
         } else {
             // Response contains no content
             $this->successful = false;
             $this->setMessage('Failed to parse a response from Klevu.');
             Mage::helper('klevu_search')->log(Zend_Log::ERR, "API response content is empty.");
         }
     } else {
         // Unsuccessful HTTP response
         $this->successful = false;
         switch ($response->getStatus()) {
             case 403:
                 $message = "Incorrect API keys.";
                 break;
             case 500:
                 $message = "API server error.";
                 break;
             case 503:
                 $message = "API server unavailable.";
                 break;
             default:
                 $message = "Unexpected error.";
         }
         $this->setMessage(sprintf("Failed to connect to Klevu: %s", $message));
         Mage::helper('klevu_search')->log(Zend_Log::ERR, sprintf("Unsuccessful HTTP response: %s %s", $response->getStatus(), $response->responseCodeAsText($response->getStatus())));
     }
     return $this;
 }
开发者ID:mSupply,项目名称:runnable_test_repo,代码行数:50,代码来源:Response.php

示例13: createResponse

 protected function createResponse(\Zend_Http_Response $response)
 {
     $headers = array($response->getHeader('Set-Cookie'));
     $cookies = array();
     foreach ($headers as $header) {
         if (!trim($header)) {
             continue;
         }
         $parts = explode(';', $header);
         $value = array_shift($parts);
         list($name, $value) = explode('=', trim($value));
         $cookies[$name] = array('value' => $value);
         foreach ($parts as $part) {
             list($key, $value) = explode('=', trim($part));
             $cookies[$name][$key] = $value;
         }
     }
     return new Response($response->getBody(), $response->getStatus(), $response->getHeaders(), $cookies);
 }
开发者ID:andreia,项目名称:Goutte,代码行数:19,代码来源:Client.php

示例14: _parseResponse

 /**
  * Parse response object and check for errors
  *
  * @param \Zend_Http_Response $response
  * @return stdClass
  */
 protected function _parseResponse(\Zend_Http_Response $response)
 {
     if ($response->isError()) {
         switch ($response->getStatus()) {
             case 401:
                 throw new Exception('Postmark request error: Unauthorized - Missing or incorrect API Key header.');
                 break;
             case 422:
                 $error = \Zend_Json::decode($response->getBody());
                 if (is_object($error)) {
                     throw new Exception(sprintf('Postmark request error: Unprocessable Entity - API error code %s, message: %s', $error->ErrorCode, $error->Message));
                 } else {
                     throw new Exception(sprintf('Postmark request error: Unprocessable Entity - API error code %s, message: %s', $error['ErrorCode'], $error['Message']));
                 }
                 break;
             case 500:
                 throw new Exception('Postmark request error: Postmark Internal Server Error');
                 break;
             default:
                 throw new Exception('Unknown error during request to Postmark server');
         }
     }
     return \Zend_Json::decode($response->getBody());
 }
开发者ID:sumoheavy,项目名称:magento2-postmark,代码行数:30,代码来源:Postmark.php

示例15: _processHttpResponse

 /**
  * Process the response
  * 
  * @param Zend_Http_Response $response
  * @return array
  * @throws Zend_Service_Exception
  */
 protected function _processHttpResponse(Zend_Http_Response $response)
 {
     // Hack for logging
     if ($this->_log instanceof Zend_Log) {
         $client = $this->getHttpClient();
         $this->_log->log(sprintf("Request:\n%s\nResponse:\n%s\n", $client->getLastRequest(), $client->getLastResponse()->asString()), Zend_Log::DEBUG);
     }
     // Check response body
     $responseData = $response->getBody();
     if (!is_string($responseData) || '' === $responseData) {
         throw new Engine_Service_2Checkout_Exception('HTTP Client returned an ' . 'empty response', 'IS_EMPTY');
     }
     // These are only supported using json
     if ('json' === $this->_format) {
         // Decode response body
         $responseData = Zend_Json::decode($responseData, Zend_Json::TYPE_ARRAY);
         if (!is_array($responseData)) {
             throw new Engine_Service_2Checkout_Exception('HTTP Client returned ' . 'invalid JSON response', 'NOT_VALID');
         }
         // Check for special global error keys
         if (!empty($responseData['errors'])) {
             foreach ($responseData['errors'] as $message) {
                 throw new Engine_Service_2Checkout_Exception(sprintf('API Error: ' . '[%1$s] %2$s', $message['code'], $message['message']), $message['code']);
             }
         }
         // Check for warnings
         if (!empty($responseData['warnings'])) {
             foreach ($responseData['warnings'] as $message) {
                 throw new Engine_Service_2Checkout_Exception(sprintf('API Warning: ' . '[%1$s] %2$s', $message['code'], $message['message']), $message['code']);
             }
         }
         // Check for response status and message
         if ('OK' !== $responseData['response_code']) {
             throw new Engine_Service_2Checkout_Exception(sprintf('Response Error: ' . '[%1$s] %2$s', $responseData['response_code'], $responseData['response_message']), $responseData['response_code']);
         }
     }
     // Check HTTP Status code
     if (200 !== $response->getStatus()) {
         // Note: looks like 2checkout gives 400 for invalid parameters
         throw new Engine_Service_2Checkout_Exception(sprintf('HTTP Client ' . 'returned error status: %1$d', $response->getStatus()), 'HTTP');
     }
     return $responseData;
 }
开发者ID:febryantosulistyo,项目名称:ClassicSocial,代码行数:50,代码来源:2Checkout.php


注:本文中的Zend_Http_Response::getStatus方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。