本文整理汇总了PHP中Zend_Http_Response类的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Http_Response类的具体用法?PHP Zend_Http_Response怎么用?PHP Zend_Http_Response使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Zend_Http_Response类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: 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());
}
}
开发者ID:rwebley,项目名称:Beowulf---PAS,代码行数:12,代码来源:Place.php
示例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);
}
开发者ID:austinphp,项目名称:crawler,代码行数:9,代码来源:FindImagesTask.php
示例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");
}
}
开发者ID:andrew-dwyer,项目名称:PINpayments,代码行数:15,代码来源:Result.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: 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
示例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__));
}
}
开发者ID:wirecard,项目名称:magento-wcs,代码行数:15,代码来源:ResponseAbstract.php
示例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);
}
}
开发者ID:sdis62,项目名称:toolbox,代码行数:20,代码来源:Response.php
示例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'];
}
}
开发者ID:jtietema,项目名称:Fizzy,代码行数:11,代码来源:Response.php
示例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;
}
开发者ID:sirprize,项目名称:rest,代码行数:11,代码来源:SimpleXml.php
示例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;
}
开发者ID:sirprize,项目名称:rest,代码行数:11,代码来源:Json.php
示例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;
}
开发者ID:BGCX261,项目名称:zrails-svn-to-git,代码行数:18,代码来源:Couchdb.php
示例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');
}
}
}
开发者ID:netzkollektiv,项目名称:wirecard-checkout-magento,代码行数:16,代码来源:Abstract.php
示例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;
}
开发者ID:sirprize,项目名称:rest,代码行数:12,代码来源:Dom.php
示例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());
}
}
开发者ID:SandeepUmredkar,项目名称:PortalSMIP,代码行数:13,代码来源:Alarm.php
示例16: processMessages
protected function processMessages(Zend_Http_Response $response)
{
$lastMessageId = 0;
$messages = json_decode($response->getBody(), true);
if (!$messages) {
return $lastMessageId;
}
foreach ($messages['messages'] as $message) {
if ($message) {
$this->triggerEvents($message);
$lastMessageId = $message['id'];
}
}
return $lastMessageId;
}
开发者ID:hhatfield,项目名称:hermes,代码行数:15,代码来源:Bot.php
示例17: _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
示例18: _postBack
/**
* Post back to PayPal to check whether this request is a valid one
*
* @return void
* @throws RemoteServiceUnavailableException
* @throws \Exception
*/
protected function _postBack()
{
$httpAdapter = $this->_curlFactory->create();
$postbackQuery = http_build_query($this->getRequestData()) . '&cmd=_notify-validate';
$postbackUrl = $this->_config->getPayPalIpnUrl();
$this->_addDebugData('postback_to', $postbackUrl);
$httpAdapter->setConfig(['verifypeer' => $this->_config->getValue('verifyPeer')]);
$httpAdapter->write(\Zend_Http_Client::POST, $postbackUrl, '1.1', ['Connection: close'], $postbackQuery);
try {
$postbackResult = $httpAdapter->read();
} catch (\Exception $e) {
$this->_addDebugData('http_error', ['error' => $e->getMessage(), 'code' => $e->getCode()]);
throw $e;
}
/*
* Handle errors on PayPal side.
*/
$responseCode = \Zend_Http_Response::extractCode($postbackResult);
if (empty($postbackResult) || in_array($responseCode, ['500', '502', '503'])) {
if (empty($postbackResult)) {
$reason = 'Empty response.';
} else {
$reason = 'Response code: ' . $responseCode . '.';
}
$this->_debugData['exception'] = 'PayPal IPN postback failure. ' . $reason;
throw new RemoteServiceUnavailableException(__($reason));
}
$response = preg_split('/^\\r?$/m', $postbackResult, 2);
$response = trim($response[1]);
if ($response != 'VERIFIED') {
$this->_addDebugData('postback', $postbackQuery);
$this->_addDebugData('postback_result', $postbackResult);
throw new \Exception('PayPal IPN postback failure. See system.log for details.');
}
}
开发者ID:BlackIkeEagle,项目名称:magento2-continuousphp,代码行数:42,代码来源:AbstractIpn.php
示例19: getLatLng
public function getLatLng($address)
{
# address identifier
$address_identifier = 'latlng_' . str_replace(array(' '), array('_'), $address);
$address_identifier = preg_replace('/[^a-z0-9_]+/i', '', $address);
# registry
$registry = Zend_Registry::getInstance();
# caching
$frontendOptions = array('lifetime' => 2592000, 'automatic_serialization' => true);
$backendOptions = array('cache_dir' => $registry->config->application->logs->tmpDir . '/cache/');
$cache = Zend_Cache::factory('Core', 'File', $frontendOptions, $backendOptions);
# get data
if (($data = $cache->load($address_identifier)) === false) {
new Custom_Logging('Hit Google: Lat/Lng for ' . $address, Zend_Log::INFO);
$client = new Zend_Http_Client('http://maps.google.com/maps/geo?q=' . urlencode($address), array('maxredirects' => 0, 'timeout' => 30));
$request = $client->request();
$response = Zend_Http_Response::fromString($request);
$body = Zend_Json::decode($response->getBody());
$data = array();
$data['latitude'] = !empty($body['Placemark'][0]['Point']['coordinates'][1]) ? $body['Placemark'][0]['Point']['coordinates'][1] : null;
$data['longitude'] = !empty($body['Placemark'][0]['Point']['coordinates'][0]) ? $body['Placemark'][0]['Point']['coordinates'][0] : null;
$cache->save($data, $address_identifier);
} else {
new Custom_Logging('(local cache) Hit Google: Lat/Lng for ' . $address, Zend_Log::INFO);
}
return $data;
}
开发者ID:MarS2806,项目名称:Zend-Framework--Doctrine-ORM--PHPUnit--Ant--Jenkins-CI--TDD-,代码行数:27,代码来源:Google.php
示例20: errorAction
/**
* Handle all API errors.
*/
public function errorAction()
{
$data = array();
$exception = $this->_getParam('error_handler')->exception;
// Add code and message to response.
$code = $exception->getCode();
if (!$code) {
$code = self::DEFAULT_HTTP_RESPONSE_CODE;
}
$message = $exception->getMessage();
if (!$message) {
$message = Zend_Http_Response::responseCodeAsText($code);
}
$data['message'] = $message;
// Add errors to response.
if ($exception instanceof Omeka_Controller_Exception_Api) {
if ($errors = $exception->getErrors()) {
$data['errors'] = $errors;
}
}
try {
$this->getResponse()->setHttpResponseCode($code);
} catch (Zend_Controller_Exception $e) {
// The response code was invalid. Set the default.
$this->getResponse()->setHttpResponseCode(self::DEFAULT_HTTP_RESPONSE_CODE);
}
$this->_helper->json($data);
}
开发者ID:lchen01,项目名称:STEdwards,代码行数:31,代码来源:ErrorController.php
注:本文中的Zend_Http_Response类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论