本文整理汇总了PHP中Zend_Http_Response::getMessage方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Http_Response::getMessage方法的具体用法?PHP Zend_Http_Response::getMessage怎么用?PHP Zend_Http_Response::getMessage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Http_Response
的用法示例。
在下文中一共展示了Zend_Http_Response::getMessage方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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());
}
}
示例2: 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;
}
示例3: 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());
}
}
示例4: _decodeResponse
/**
* Decode request response
*
* @param Zend_Http_Response $response response of request
* @throws Zend_Db_Exception
* @return array
*/
protected function _decodeResponse(Zend_Http_Response $response)
{
$result = Zend_Json::decode($response->getBody());
if (is_null($result)) {
throw new Zend_Db_Exception($response->getMessage());
}
if ($result["error"]) {
throw new Exception($result["reason"], $this->_errors[$result["error"]]);
}
return $result;
}
示例5: doRequest
/**
* @param bool $checkForErrors
* @return $this
* @throws Mage_Core_Exception
*/
public function doRequest($checkForErrors = true)
{
$helper = Mage::helper('core/translate');
$this->_applyFilters();
if (!$this->_http->getUri()) {
Mage::throwException($helper->__('Undefined request method'));
}
try {
$this->result = $this->_http->request();
} catch (Exception $e) {
Mage::throwException('Can\'t process request');
}
if (!in_array($this->result->getStatus(), $this->allowedStatuses) && $checkForErrors) {
$body = json_decode($this->result->getBody());
Mage::throwException($body->error ? $body->error : $this->result->getMessage());
}
return $this;
}
示例6: _checkResponse
/**
* Checks ReST response for errors.
*
* @param Zend_Http_Response $response the ReST response
* @return void
* @throws Zend_Service_Technorati_Exception
* @access protected
*/
protected static function _checkResponse(Zend_Http_Response $response)
{
if ($response->isError()) {
/**
* @see Zend_Service_Technorati_Exception
*/
// require_once 'Zend/Service/Technorati/Exception.php';
throw new Zend_Service_Technorati_Exception(sprintf('Invalid response status code (HTTP/%s %s %s)', $response->getVersion(), $response->getStatus(), $response->getMessage()));
}
}
示例7: _getData
/**
* Returns data of the call if there was no error
*
* @throws Robo47_Service_Bitly_Exception
* @param Zend_Http_Response $response
* @return string|array|object
*/
protected function _getData(Zend_Http_Response $response)
{
if ($response->isError()) {
$message = 'Error on api-call: ' . $response->getMessage();
throw new Robo47_Service_Bitly_Exception($message);
}
// find errors without parsing xml / json
// @todo parse formats always and move tests into the other switch
// and refactor a bit, method gets big and ugly
switch ($this->_format) {
case self::FORMAT_XML:
$regex = preg_quote('<errorCode>0</errorCode>', '/');
break;
case self::FORMAT_JSON:
$regex = preg_quote('"errorCode": 0', '/');
break;
}
if (!preg_match('/' . $regex . '/i', $response->getBody())) {
$message = 'Error on api-call: no errorCode=0 found';
throw new Robo47_Service_Bitly_Exception($message);
}
// @todo checking for errors ALWAYS!
switch ($this->_resultFormat) {
case self::FORMAT_RESULT_NATIVE:
$result = $response->getBody();
break;
case self::FORMAT_RESULT_ARRAY:
switch ($this->_format) {
case self::FORMAT_XML:
$result = $this->xmlToArray($response->getBody());
break;
case self::FORMAT_JSON:
$result = json_decode($response->getBody(), true);
break;
}
break;
case self::FORMAT_RESULT_OBJECT:
switch ($this->_format) {
case self::FORMAT_XML:
$result = $this->xmlToObject($response->getBody());
break;
case self::FORMAT_JSON:
$result = json_decode($response->getBody(), false);
break;
}
break;
}
return $result;
}
示例8: prepareResponse
/**
* Prepare a solarium response from the given request and client
* response
*
* @throws HttpException
* @param Request $request
* @param \Zend_Http_Response $response
* @return Response
*/
protected function prepareResponse($request, $response)
{
if ($response->isError()) {
throw new HttpException($response->getMessage(), $response->getStatus());
}
if ($request->getMethod() == Request::METHOD_HEAD) {
$data = '';
} else {
$data = $response->getBody();
}
// this is used because getHeaders doesn't return the HTTP header...
$headers = explode("\n", $response->getHeadersAsString());
return new Response($data, $headers);
}
示例9: _checkResponse
/**
* Checks ReST response for errors.
*
* @param Zend_Http_Response $response the ReST response
* @return void
* @throws Zend_Service_Technorati_Exception
* @access protected
*/
protected static function _checkResponse(Zend_Http_Response $response)
{
if ($response->isError()) {
throw new Zend_Service_Technorati_Exception(sprintf('Invalid response status code (HTTP/%s %s %s)', $response->getVersion(), $response->getStatus(), $response->getMessage()));
}
}
示例10: _parseResponse
/**
* Search for error from request.
*
* If any error is found a DOMDocument is returned, this object contains a
* DOMXPath object as "ebayFindingXPath" attribute.
*
* @param Zend_Http_Response $response
* @throws Zend_Service_Ebay_Trading_Exception When any error occurrs during request
* @return SimpleXMLElement
*/
protected function _parseResponse(Zend_Http_Response $response)
{
// error message
$message = '';
// first trying, loading XML
$xml = simplexml_load_string($response->getBody());
if (!$xml) {
$message = 'It was not possible to load XML returned.';
}
if ($xml->Ack != 'Success') {
$message = 'Ack not success.';
}
// second trying, check request status
if ($response->isError()) {
$message = $response->getMessage() . ' (HTTP status code #' . $response->getStatus() . ')';
}
// throw exception when an error was detected
if (strlen($message) > 0) {
/**
* @see Zend_Service_Ebay_Finding_Exception
*/
require_once 'Zend/Service/Ebay/Trading/Exception.php';
throw new Zend_Service_Ebay_Trading_Exception($message);
}
return $xml;
}
示例11: initializeResponse
/**
* Initializes response object.
*
* @param Zend_Http_Response $response
*
* @return Jirafe_HttpConnection_Response
*/
protected function initializeResponse(Zend_Http_Response $response)
{
return new Jirafe_HttpConnection_Response($response->getBody(), $response->getHeaders(), $response->isError() ? $response->getStatus() : 0, $response->getMessage());
}
示例12: _parseResponse
/**
* Search for error from request.
*
* If any error is found a DOMDocument is returned, this object contains a
* DOMXPath object as "ebayFindingXPath" attribute.
*
* @param Zend_Http_Response $response
* @throws Zend_Service_Ebay_Trading_Exception When any error occurrs during request
* @return SimpleXMLElement
*/
protected function _parseResponse(Zend_Http_Response $response)
{
// error message
$message = '';
$xml = simplexml_load_string($response->getBody());
if (!$xml) {
$message = 'It was not possible to load XML returned.';
}
if ($xml->Ack != 'Success' && $xml->Ack != 'Warning') {
$message = "Ack not success: " . print_r($xml, true);
}
//var_dump($dom->Ack);die;
// second trying, check request status
if ($response->isError()) {
$message = $response->getMessage() . ' (HTTP status code #' . $response->getStatus() . ')';
}
// throw exception when an error was detected
if (strlen($message) > 0) {
/**
* @see Zend_Service_Ebay_Finding_Exception
*/
require_once 'Zend/Service/Ebay/Shopping/Exception.php';
throw new Zend_Service_Ebay_Shopping_Exception($message);
}
/*
$dom = new DOMDocument();
$dom->loadXML($response->getBody());
Zend_Debug::dump($dom->saveXML());
Zend_Debug::dump($xml);
*/
return $xml;
}
示例13: _processResult
/**
* Check status code and if appropriate return the decoded JSON
*
* @param Zend_Http_Response $response
* @return array
* @throws Zend_Service_Exception
*/
protected function _processResult(Zend_Http_Response $response)
{
if ($response->getStatus() != 200) {
require_once 'Zend/Service/Exception.php';
throw new Zend_Service_Exception('Postmark returned ' . $response->getStatus() . ' - ' . $response->getMessage());
}
return json_decode($response->getBody());
}