本文整理汇总了PHP中Zend_Http_Response::isSuccessful方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Http_Response::isSuccessful方法的具体用法?PHP Zend_Http_Response::isSuccessful怎么用?PHP Zend_Http_Response::isSuccessful使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Http_Response
的用法示例。
在下文中一共展示了Zend_Http_Response::isSuccessful方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: wasSuccess
/**
* Determines if the last request was a success (1** - 2** code).
*
* @return boolean
*/
protected function wasSuccess()
{
if (!isset($this->lastResponse)) {
$this->handleError("Request has not been sent to the API");
return false;
}
return $this->lastResponse->isSuccessful();
}
示例2: _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;
}
示例3: 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());
}
}
示例4: _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;
}
示例5: 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;
}
示例6: isError
/**
* Did an error occur in the request?
*
* @return bool
*/
public function isError()
{
return !$this->httpResponse->isSuccessful();
}
示例7: parseResponse
/**
* Throw an exception if error occured
*
* @param SimpleXMLElement $xml
* @return SimpleXMLElement
*/
private function parseResponse(\Zend_Http_Response $response)
{
if (!$response->isSuccessful()) {
throw new \RuntimeException("Response not successful.");
}
$xml = simplexml_load_string($response->getBody());
if ($xml->getName() !== 'newsMessage' && !in_array((int) $xml->status['code'], array(self::STATUS_SUCCESS, self::STATUS_PARTIAL_SUCCESS))) {
throw new \RuntimeException((string) $xml->status->error);
}
return $xml;
}
示例8: _getHandlerKey
/**
* return a string that is a key to the handler config for the class of status codes.
* @param Zend_Http_Response $response
* @return string
*/
protected function _getHandlerKey(Zend_Http_Response $response = null)
{
if ($response) {
$code = $response->getStatus();
if ($response->isSuccessful() || $response->isRedirect()) {
return 'success';
} elseif ($code < 500 && $code >= 400) {
return 'client_error';
} elseif ($code >= 500) {
return 'server_error';
}
// @codeCoverageIgnoreStart
}
// @codeCoverageIgnoreEnd
return 'no_response';
}