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


PHP Response::isSuccessful方法代碼示例

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


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

示例1: getResponse

 /**
  * Get the response of the query.
  * Will be the json decoded data if success, else the error message.
  *
  * @return array|string
  */
 public function getResponse()
 {
     if (false === $this->response->isSuccessful()) {
         return $this->response->getMessage();
     }
     return $this->response->json();
 }
開發者ID:pompdelux,項目名稱:kraken-bundle,代碼行數:13,代碼來源:KrakenResponse.php

示例2: getDelay

 protected function getDelay($retries, RequestInterface $request, Response $response = null, HttpException $e = null)
 {
     if ($response) {
         if ($response->isSuccessful()) {
             return false;
         } else {
             return isset($this->errorCodes[$response->getStatusCode()]) ? true : null;
         }
     }
 }
開發者ID:Ryu0621,項目名稱:SaNaVi,代碼行數:10,代碼來源:HttpBackoffStrategy.php

示例3: __construct

 /**
  * @param \Guzzle\Http\Message\Response $response
  */
 public function __construct(\Guzzle\Http\Message\Response $response)
 {
     if ($response->isSuccessful()) {
         $this->response = $response->json();
         foreach ($this->response as $key => $value) {
             $this->response[$key] = $value;
         }
     } else {
         // TODO: Error handling
     }
 }
開發者ID:Atyz,項目名稱:etherpad-lite-client,代碼行數:14,代碼來源:Response.php

示例4: handleResponse

 /**
  * @param Event $event
  *
  * @throws \RuntimeException|ExceptionInterface
  */
 protected function handleResponse(Event $event)
 {
     $this->response = $event['response'];
     if ($this->response->isSuccessful()) {
         return;
     }
     $body = $this->response->getBody(true);
     $code = $this->response->getStatusCode();
     if ($this->exception) {
         throw $this->exception->create($body, $code);
     }
     $content = json_decode($body);
     throw new \RuntimeException(sprintf('[%d] %s (%s)', $code, $content->message, $content->id), $code);
 }
開發者ID:fideloper,項目名稱:DigitalOceanV2,代碼行數:19,代碼來源:GuzzleAdapter.php

示例5: getDelay

 protected function getDelay($retries, RequestInterface $request, Response $response = null, HttpException $e = null)
 {
     if ($response) {
         //Short circuit the rest of the checks if it was successful
         if ($response->isSuccessful()) {
             return false;
         } else {
             if (isset($this->errorCodes[$response->getStatusCode()])) {
                 if ($response->getHeader("Retry-After")) {
                     return $response->getHeader("Retry-After")->__toString();
                 } else {
                     return self::$defaultRetryAfter;
                 }
             } else {
                 return null;
             }
         }
     }
 }
開發者ID:keboola,項目名稱:provisioning-client,代碼行數:19,代碼來源:MaintenanceBackoffStrategy.php

示例6: isHttpErrorFatal

 /**
  * @return bool
  */
 private function isHttpErrorFatal(Response $response, $expectedResponseContentType)
 {
     return $response->isSuccessful() && $response->getContentType() != $expectedResponseContentType;
 }
開發者ID:rezzza,項目名稱:tk1-contexts,代碼行數:7,代碼來源:HttpResponseTimeBenchmark.php

示例7: testIsSuccessful

 /**
  * @covers Guzzle\Http\Message\Response::isSuccessful
  */
 public function testIsSuccessful()
 {
     $response = new Response(200);
     $this->assertTrue($response->isSuccessful());
     $response = new Response(403);
     $this->assertFalse($response->isSuccessful());
 }
開發者ID:KANU82,項目名稱:guzzle,代碼行數:10,代碼來源:ResponseTest.php

示例8: canCacheResponse

 public function canCacheResponse(Response $response)
 {
     return $response->isSuccessful() && $response->canCache();
 }
開發者ID:Trideon,項目名稱:gigolo,代碼行數:4,代碼來源:DefaultCanCacheStrategy.php

示例9: processResponse

 private function processResponse(Response $response)
 {
     if (!$response->isSuccessful()) {
         throw new ApiServerException($response->getMessage(), $response->getStatusCode());
     }
     if (self::FORMAT_ARRAY === $this->outputFormat) {
         return $response->json();
     }
     return $response->getBody(true);
 }
開發者ID:bitblower,項目名稱:mailjet-api-php,代碼行數:10,代碼來源:Client.php

示例10: log

 /**
  * Log a message based on a request and response
  *
  * @param RequestInterface $request  Request to log
  * @param Response         $response Response to log
  */
 private function log(RequestInterface $request, Response $response = null)
 {
     $message = '';
     if ($this->settings & self::LOG_CONTEXT) {
         // Log common contextual information
         $message = $request->getHost() . ' - "' . $request->getMethod() . ' ' . $request->getResource() . ' ' . strtoupper($request->getScheme()) . '/' . $request->getProtocolVersion() . '"';
         // If a response is set, then log additional contextual information
         if ($response) {
             $message .= sprintf(' - %s %s - %s %s %s', $response->getStatusCode(), $response->getContentLength() ?: 0, $response->getInfo('total_time'), $response->getInfo('speed_upload'), $response->getInfo('speed_download'));
         }
     }
     // Check if we are logging anything that will come from cURL
     if ($request->getParams()->get('curl_handle') && ($this->settings & self::LOG_DEBUG || $this->settings & self::LOG_HEADERS || $this->settings & self::LOG_BODY)) {
         // If context logging too, then add a new line for cleaner messages
         if ($this->settings & self::LOG_CONTEXT) {
             $message .= "\n";
         }
         // Filter cURL's verbose output based on config settings
         $message .= $this->parseCurlLog($request);
         // Log the response body if the response is available
         if ($this->settings & self::LOG_BODY && $response) {
             if ($request->getParams()->get('response_wire')) {
                 $message .= (string) $request->getParams()->get('response_wire');
             } else {
                 $message .= $response->getBody(true);
             }
         }
     }
     // Send the log message to the adapter, adding a category and host
     $priority = $response && !$response->isSuccessful() ? LOG_ERR : LOG_DEBUG;
     $this->logAdapter->log(trim($message), $priority, array('category' => 'guzzle.request', 'host' => $this->hostname));
 }
開發者ID:nickpeirson,項目名稱:guzzle,代碼行數:38,代碼來源:LogPlugin.php

示例11: isSuccessful

 /**
  * {@inheritdoc}
  */
 public function isSuccessful()
 {
     return $this->response->isSuccessful();
 }
開發者ID:ramunasd,項目名稱:platform,代碼行數:7,代碼來源:GuzzleRestResponse.php

示例12: __construct

 public function __construct(RequestInterface $request, HttpResponse $response)
 {
     parent::__construct($request, $response->xml());
     $this->isSuccessful = $response->isSuccessful();
 }
開發者ID:bamarni,項目名稱:omnipay-ideal,代碼行數:5,代碼來源:FetchIssuersResponse.php

示例13: isSuccess

 /**
  * @return bool
  */
 public function isSuccess()
 {
     return $this->guzzleResponse->isSuccessful();
 }
開發者ID:peterculak,項目名稱:apis,代碼行數:7,代碼來源:Response.php


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