當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Response::isOk方法代碼示例

本文整理匯總了PHP中Zend\Http\Response::isOk方法的典型用法代碼示例。如果您正苦於以下問題:PHP Response::isOk方法的具體用法?PHP Response::isOk怎麽用?PHP Response::isOk使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Zend\Http\Response的用法示例。


在下文中一共展示了Response::isOk方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: checkStatusCode

 /**
  * Checks whether to handle this status code.
  *
  * @param  HttpResponse $response
  * @return boolean
  */
 public function checkStatusCode(HttpResponse $response)
 {
     // Only 200 responses are cached by default
     if (empty($this->config['http_codes_black_list'])) {
         return $response->isOk();
     }
     $statusCode = $response->getStatusCode();
     return !in_array($statusCode, (array) $this->config['http_codes_black_list']);
 }
開發者ID:zfcampus,項目名稱:zf-http-cache,代碼行數:15,代碼來源:HttpCacheListener.php

示例2: send

 /**
  * Send Http request to retrieve datas
  * @access protected
  * @param  string                                $service    Service to call
  * @param  string                                $type       Resource type to retrieve (for search service)
  * @param  array                                 $parameters Parameters used for request
  * @throws \Zend\Http\Exception\RuntimeException
  * @return \stdClass
  */
 protected function send($service, $type, $parameters)
 {
     // reset old parameters
     $this->getHttpClient()->resetParameters();
     // setup Http headers
     $headers = array(ContentTypeHeader::fromString('Content-Type: ' . HttpClient::ENC_URLENCODED));
     // setup HttpClient
     $this->getHttpClient()->setMethod(HttpRequest::METHOD_GET);
     $this->getHttpClient()->setParameterGet($parameters);
     $this->getHttpClient()->setHeaders($headers);
     // generate URI and set to HttpClient
     $this->getHttpClient()->setUri($this->generateURI($service, $type));
     // get HttpResponse
     $this->response = $this->getHttpClient()->send();
     // is HttpRequest ok ?
     if (!$this->response->isOk()) {
         // throw RuntimeException
         throw new ZendRuntimeException(sprintf('Invalid status code: %d', $this->response->getStatusCode()));
     }
     // return decode object
     return \Zend\Json\Decoder::decode($this->response->getBody());
 }
開發者ID:ze-pequeno,項目名稱:pequeno-spotify-module,代碼行數:31,代碼來源:SpotifyService.php


注:本文中的Zend\Http\Response::isOk方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。