当前位置: 首页>>代码示例>>PHP>>正文


PHP Response::getStatusCode方法代码示例

本文整理汇总了PHP中GuzzleHttp\Psr7\Response::getStatusCode方法的典型用法代码示例。如果您正苦于以下问题:PHP Response::getStatusCode方法的具体用法?PHP Response::getStatusCode怎么用?PHP Response::getStatusCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在GuzzleHttp\Psr7\Response的用法示例。


在下文中一共展示了Response::getStatusCode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: retryDecider

 static function retryDecider($retries, Request $request, Response $response = null, RequestException $exception = null)
 {
     // Limit the number of retries to 5
     if ($retries >= 5) {
         return false;
     }
     // Retry connection exceptions
     if ($exception instanceof ConnectException) {
         return true;
     }
     if ($response) {
         // Retry on server errors
         if ($response->getStatusCode() >= 500) {
             return true;
         }
         // Retry on rate limits
         if ($response->getStatusCode() == 429) {
             $retryDelay = $response->getHeaderLine('Retry-After');
             if (strlen($retryDelay)) {
                 printf(" retry delay: %d secs\n", (int) $retryDelay);
                 sleep((int) $retryDelay);
                 return true;
             }
         }
     }
     return false;
 }
开发者ID:andig,项目名称:spotify-web-api-extensions,代码行数:27,代码来源:GuzzleClientFactory.php

示例2: setErrorResponse

 /**
  * @param GuzzleException $guzzleException
  */
 public function setErrorResponse(GuzzleException $guzzleException)
 {
     $this->exception = $guzzleException;
     if ($guzzleException instanceof RequestException) {
         $this->response = $guzzleException->getResponse();
         $this->status = $this->response->getStatusCode();
     }
     $this->timeResponse = microtime(true);
 }
开发者ID:FreezyBee,项目名称:MailChimp,代码行数:12,代码来源:Resource.php

示例3: isSuccessful

 /**
  * Check response content is successful or not
  *
  * @return boolean
  */
 public function isSuccessful()
 {
     $statusCode = $this->response->getStatusCode();
     if ($statusCode == self::STATUS_CONSUME_OK || $statusCode == self::STATUS_DELETE_OK || $statusCode == self::STATUS_PRODUCE_OK) {
         return true;
     }
     $this->errorMessage = self::$status[$statusCode];
     return false;
 }
开发者ID:goqihoo,项目名称:aliyun,代码行数:14,代码来源:Response.php

示例4: deduce

 /**
  * @return ErrorResponse|SuccessResponse
  */
 public function deduce()
 {
     /* @var array $response */
     $response = (array) json_decode($this->response->getBody()->getContents());
     if (array_key_exists('type', $response) && $response['type'] === 'error') {
         return new ErrorResponse($this->response->getStatusCode(), $this->response->getHeaders(), $this->response->getBody());
     }
     return new SuccessResponse($this->response->getStatusCode(), $this->response->getHeaders(), $this->response->getBody());
 }
开发者ID:NeokamiCode,项目名称:box-php-sdk,代码行数:12,代码来源:Response.php

示例5: connect

 /**
  * Connect to server.
  */
 private function connect()
 {
     $headers = [];
     if ($this->lastId) {
         $headers['Last-Event-ID'] = $this->lastId;
     }
     $this->response = $this->client->request('GET', $this->url, ['stream' => true, 'headers' => $headers]);
     if ($this->response->getStatusCode() == 204) {
         throw new RuntimeException('Server forbid connection retry by responding 204 status code.');
     }
 }
开发者ID:obsh,项目名称:sse-client,代码行数:14,代码来源:Client.php

示例6: isJsonResponse

 /**
  * Check if the response given by fcm is parsable
  *
  * @param GuzzleResponse $response
  *
  * @throws InvalidRequestException
  * @throws ServerResponseException
  * @throws UnauthorizedRequestException
  */
 private function isJsonResponse(GuzzleResponse $response)
 {
     if ($response->getStatusCode() == 200) {
         return;
     }
     if ($response->getStatusCode() == 400) {
         throw new InvalidRequestException($response);
     }
     if ($response->getStatusCode() == 401) {
         throw new UnauthorizedRequestException($response);
     }
     throw new ServerResponseException($response);
 }
开发者ID:brozot,项目名称:laravel-fcm,代码行数:22,代码来源:BaseResponse.php

示例7: search

 /**
  * Search book by tags like title, author, publisher etc.
  *
  * @param array $query
  *
  * @return mixed
  */
 public function search(array $query)
 {
     $processed = $this->transformQueryParameters($query, $this->queryTransformationMap());
     $query = implode(' ', $processed[1]);
     foreach ($processed[0] as $key => $value) {
         $query .= ' ' . $key . $value;
     }
     $query = $this->prepareQuery($query);
     $this->response = $this->client->get($query);
     if ($this->response->getStatusCode() != 200) {
         $this->response = null;
     }
     return $this;
 }
开发者ID:znck,项目名称:livre,代码行数:21,代码来源:GoogleBooks.php

示例8: make

 public static function make(Response $response)
 {
     $code = $response->getStatusCode();
     $body = json_decode($response->getBody(), true);
     if ($response->getStatusCode() == 200) {
         if (!is_array($body) && is_string($body)) {
             $body = ['message' => $body];
         }
     } else {
         if (!$body['message']) {
             $body = ['message' => $response->getReasonPhrase(), 'details' => $body];
         }
     }
     return new RuleResponse($code, $body);
 }
开发者ID:rulecom,项目名称:api-wrapper,代码行数:15,代码来源:ResponseFactory.php

示例9: create

 /**
  * @param Response $response
  * @return AuthorizationResponse
  */
 public function create(Response $response)
 {
     if ($response->getStatusCode() === 200) {
         return new AuthorizationResponse($response, AuthorizationResponse::AUTHORISED);
     }
     return new AuthorizationResponse($response, AuthorizationResponse::UNAUTHORISED);
 }
开发者ID:gsdevme,项目名称:jumpcloud,代码行数:11,代码来源:AuthorizationResponseFactory.php

示例10: setLastLogs

 /**
  * Set last logs
  *
  * @param Response|ResponseInterface $response
  */
 public function setLastLogs($response)
 {
     $this->statusCode = $response->getStatusCode();
     $content = json_decode($response->getBody()->getContents());
     $this->message = isset($content->message) ? $content->message : null;
     $this->errors = isset($content->errors) ? $content->errors : null;
 }
开发者ID:plescanicolai,项目名称:billingSdk,代码行数:12,代码来源:Auth.php

示例11: getJsonResponse

 public static function getJsonResponse(GuzzleHttp\Psr7\Response $res)
 {
     if ($res->getStatusCode() == 200) {
         return json_decode($res->getBody()->getContents(), true);
     }
     return [];
 }
开发者ID:jrm2k6,项目名称:laradit,代码行数:7,代码来源:APIRequestHelper.php

示例12: updateGame

 protected function updateGame(\Morpheus\SteamGame $game, \GuzzleHttp\Psr7\Response $response)
 {
     $body = json_decode($response->getBody());
     $result = reset($body);
     if ($response->getStatusCode() == 200 && isset($result->success) && $result->success === true) {
         $game->steam_store_data = json_encode($result->data);
     } elseif ($response->getStatusCode() !== 200) {
         \Log::warning('Steam Store API call failed', ['status code' => $response->getStatusCode(), 'game' => $game]);
     } elseif (!isset($result->success)) {
         \Log::warning('Unexpected Steam Store API response', ['body' => $result, 'game' => $game]);
     } else {
         \Log::notice('Game not found in Steam Store database', ['game' => $game]);
     }
     $game->steam_store_updated = date('Y-m-d H:i:s');
     $game->save();
 }
开发者ID:kamicollo,项目名称:ProjectMorpheus,代码行数:16,代码来源:SteamStoreGames.php

示例13: sendOrchestratorPollRequest

 /**
  * Send poll request from task response
  *
  * If response is not from async task, return null
  *
  * @param Elasticsearch\Job $job
  * @param \GuzzleHttp\Psr7\Response $response
  * @param Encryptor $encryptor
  * @param int $retriesCount
  * @return \GuzzleHttp\Psr7\Response|null
  */
 public function sendOrchestratorPollRequest(Elasticsearch\Job $job, \GuzzleHttp\Psr7\Response $response, Encryptor $encryptor, $retriesCount)
 {
     if ($response->getStatusCode() != 202) {
         return null;
     }
     try {
         $data = ResponseDecoder::decode($response);
         if (!is_array($data)) {
             throw new \Exception('Not json reponse');
         }
         if (empty($data['url'])) {
             return null;
         }
     } catch (\Exception $e) {
         //@TODO log error with debug priority
         return null;
     }
     $timeout = 2;
     try {
         return $this->get($data['url'], array('config' => array('curl' => array(CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_0)), 'headers' => array('X-StorageApi-Token' => $encryptor->decrypt($job->getToken()), 'X-KBC-RunId' => $job->getRunId(), 'X-User-Agent', KeboolaOrchestratorBundle::SYRUP_COMPONENT_NAME . " - JobExecutor", 'X-Orchestrator-Poll', (int) $retriesCount), 'timeout' => 60 * $timeout));
     } catch (RequestException $e) {
         $handlerContext = $e->getHandlerContext();
         if (is_array($handlerContext)) {
             if (array_key_exists('errno', $handlerContext)) {
                 if ($handlerContext['errno'] == CURLE_OPERATION_TIMEOUTED) {
                     $this->logger->debug('curl.debug', array('handlerContext' => $e->getHandlerContext()));
                     throw new Exception\CurlException(sprintf('Task polling timeout after %d minutes', $timeout), $e->getRequest(), $e->getResponse(), $e);
                 }
             }
         }
         throw $e;
     }
 }
开发者ID:keboola,项目名称:orchestrator-bundle,代码行数:44,代码来源:Client.php

示例14: handleError

 /**
  * @throws HttpException
  */
 protected function handleError()
 {
     $body = (string) $this->response->getBody();
     $code = (int) $this->response->getStatusCode();
     $content = json_decode($body);
     throw new HttpException(isset($content->message) ? $content->message : 'Request not processed.', $code);
 }
开发者ID:mix376,项目名称:DigitalOceanV2,代码行数:10,代码来源:GuzzleHttpAdapter.php

示例15: shouldRetry

 /**
  * Indicates if there should be a retry or not.
  * 
  * @param integer                   $retryCount The retry count.
  * @param \GuzzleHttp\Psr7\Response $response   The HTTP response object.
  * 
  * @return boolean
  */
 public function shouldRetry($retryCount, $response)
 {
     if ($retryCount >= $this->_maximumAttempts || array_search($response->getStatusCode(), $this->_retryableStatusCodes) || is_null($response)) {
         return false;
     } else {
         return true;
     }
 }
开发者ID:Azure,项目名称:azure-storage-php,代码行数:16,代码来源:ExponentialRetryPolicy.php


注:本文中的GuzzleHttp\Psr7\Response::getStatusCode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。