本文整理汇总了PHP中Zend_Http_Response类的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Http_Response类的具体用法?PHP Zend_Http_Response怎么用?PHP Zend_Http_Response使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Zend_Http_Response类的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());
}
}
示例2: formatResponse
/** Set up the response rendering
*
* @param string $response
*/
public function formatResponse(Zend_Http_Response $response)
{
if ('json' === $this->getResponseType()) {
return json_decode($response->getBody());
} else {
return new Zend_Rest_Client_Result($response->getBody());
}
}
示例3: task
public function task(Zend_Http_Response $response, Zend_Http_Client $client)
{
$query = new Zend_Dom_Query($response->getBody());
$images = $query->query('img');
foreach ($images as $image) {
$this->images[] = $image->getAttribute('src');
}
$this->images = array_unique($this->images);
}
示例4: __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");
}
}
示例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;
}
示例6: 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());
}
}
示例7: __construct
/**
* base constructor for Response objects
*
* @param Zend_Http_Response $response
*/
public function __construct($response)
{
if ($response instanceof Zend_Http_Response) {
$this->_response = WirecardCEE_Stdlib_SerialApi::decode($response->getBody());
} elseif (is_array($response)) {
$this->_response = $response;
} else {
throw new WirecardCEE_Stdlib_Exception_InvalidResponseException(sprintf('Invalid response from WirecardCEE thrown in %s.', __METHOD__));
}
}
示例8: __construct
/**
* Constructeur
*
* Affecte la réponse HTTP à une propriété, ainsi que le body.
* Il tente ensuite de déchiffrer le corps en tant que JSON.
*
* @param Zend_Http_Response $httpResponse
* @throws SDIS62_Service_Generic_Exception
*/
public function __construct(Zend_Http_Response $httpResponse)
{
$this->httpResponse = $httpResponse;
$this->rawBody = $httpResponse->getBody();
try {
$jsonBody = Zend_Json::decode($this->rawBody, Zend_Json::TYPE_OBJECT);
$this->jsonBody = $jsonBody;
} catch (Zend_Json_Exception $e) {
throw new SDIS62_Service_Generic_Exception('impossible de décoder la réponse: ' . $e->getMessage(), 0, $e);
}
}
示例9: __construct
public function __construct(Zend_Http_Response $response)
{
$body = $response->getRawBody();
$json = Zend_Json::decode($body);
$this->_id = $json['id'];
if (null !== $json['error']) {
$this->_error = $json['error'];
} else {
$this->_result = $json['result'];
}
}
示例10: load
public function load(\Zend_Http_Response $httpResponse)
{
$this->_reset();
if ($httpResponse->getBody()) {
set_error_handler(array($this, 'handleLoadErrors'));
$this->_simpleXml = simplexml_load_string($httpResponse->getBody());
restore_error_handler();
}
$this->_httpResponse = $httpResponse;
return $this;
}
示例11: load
public function load(\Zend_Http_Response $httpResponse)
{
$this->_reset();
if ($httpResponse->getBody()) {
set_error_handler(array($this, 'handleLoadErrors'));
$this->_json = json_decode($httpResponse->getBody());
restore_error_handler();
}
$this->_httpResponse = $httpResponse;
return $this;
}
示例12: _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;
}
示例13: __construct
/**
* base ctor for Response objects
* @param Zend_Http_Response $response
*/
public function __construct($response)
{
if ($response instanceof Zend_Http_Response) {
$this->_response = WirecardCEE_SerialApi::decode($response->getBody());
} else {
if (is_array($response)) {
$this->_response = $response;
} else {
throw new WirecardCEE_Exception('Invalid response from WirecardCEE');
}
}
}
示例14: load
public function load(\Zend_Http_Response $httpResponse)
{
$this->_reset();
if ($httpResponse->getBody()) {
set_error_handler(array($this, 'handleLoadErrors'));
$this->_dom = new \DOMDocument();
$this->_dom->loadXml($httpResponse->getBody());
restore_error_handler();
}
$this->_httpResponse = $httpResponse;
return $this;
}
示例15: 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());
}
}