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


PHP Message\ResponseInterface類代碼示例

本文整理匯總了PHP中GuzzleHttp\Message\ResponseInterface的典型用法代碼示例。如果您正苦於以下問題:PHP ResponseInterface類的具體用法?PHP ResponseInterface怎麽用?PHP ResponseInterface使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1: parse

 public function parse(Session $rets, ResponseInterface $response, $parameters)
 {
     $xml = $response->xml();
     $rs = new Results();
     $rs->setSession($rets)->setResource($parameters['SearchType'])->setClass($parameters['Class']);
     if ($this->getRestrictedIndicator($rets, $xml, $parameters)) {
         $rs->setRestrictedIndicator($this->getRestrictedIndicator($rets, $xml, $parameters));
     }
     $rs->setHeaders($this->getColumnNames($rets, $xml, $parameters));
     $rets->debug(count($rs->getHeaders()) . ' column headers/fields given');
     $this->parseRecords($rets, $xml, $parameters, $rs);
     if ($this->getTotalCount($rets, $xml, $parameters) !== null) {
         $rs->setTotalResultsCount($this->getTotalCount($rets, $xml, $parameters));
         $rets->debug($rs->getTotalResultsCount() . ' total results found');
     }
     $rets->debug($rs->getReturnedResultsCount() . ' results given');
     if ($this->foundMaxRows($rets, $xml, $parameters)) {
         // MAXROWS tag found.  the RETS server withheld records.
         // if the server supports Offset, more requests can be sent to page through results
         // until this tag isn't found anymore.
         $rs->setMaxRowsReached();
         $rets->debug('Maximum rows returned in response');
     }
     unset($xml);
     return $rs;
 }
開發者ID:mitchlayzell,項目名稱:PHRETS,代碼行數:26,代碼來源:OneX.php

示例2: decodeHttpResponse

 /**
  * Decode an HTTP Response.
  * @static
  * @throws Google_Service_Exception
  * @param GuzzleHttp\Message\RequestInterface $response The http response to be decoded.
  * @param GuzzleHttp\Message\ResponseInterface $response
  * @return mixed|null
  */
 public static function decodeHttpResponse(ResponseInterface $response, RequestInterface $request = null)
 {
     $body = (string) $response->getBody();
     $code = $response->getStatusCode();
     $result = null;
     // return raw response when "alt" is "media"
     $isJson = !($request && 'media' == $request->getQuery()->get('alt'));
     // set the result to the body if it's not set to anything else
     if ($isJson) {
         try {
             $result = $response->json();
         } catch (ParseException $e) {
             $result = $body;
         }
     } else {
         $result = $body;
     }
     // retry strategy
     if (intVal($code) >= 300) {
         $errors = null;
         // Specific check for APIs which don't return error details, such as Blogger.
         if (isset($result['error']) && isset($result['error']['errors'])) {
             $errors = $result['error']['errors'];
         }
         throw new Google_Service_Exception($body, $code, null, $errors);
     }
     return $result;
 }
開發者ID:OlivierBarbier,項目名稱:google-api-php-client,代碼行數:36,代碼來源:REST.php

示例3: populateFromResponse

 /**
  * {@inheritDoc}
  */
 public function populateFromResponse(ResponseInterface $response)
 {
     $entries = $response->json()['access']['serviceCatalog'];
     foreach ($entries as $entry) {
         $this->entries[] = $this->model('Entry', $entry);
     }
 }
開發者ID:boxrice007,項目名稱:openstack,代碼行數:10,代碼來源:Catalog.php

示例4: handleResponse

 /**
  * @param ResponseInterface $response
  */
 private function handleResponse(ResponseInterface $response, Request $request)
 {
     $context = $this->prepareBaseContext($request);
     $data = $response->json();
     if (isset($data['results'])) {
         foreach ($data['results'] as $registrationIdIdx => $result) {
             $context['registrationId'] = $this->registrationIds[$registrationIdIdx];
             $context['result'] = var_export($result, true);
             switch (key($result)) {
                 case 'message_id':
                     if (isset($result['registration_id'])) {
                         $this->callback(EventsEnum::ON_PUSH_SUCCESS_BUT_NEED_NEW_ID, [$context]);
                     } else {
                         $this->callback(EventsEnum::ON_PUSH_SUCCESS, [$context]);
                     }
                     break;
                 case 'error':
                     $currentResult = current($result);
                     switch ($currentResult) {
                         case 'Unavailable':
                             $this->callback(EventsEnum::ON_PUSH_UNAVAILABLE, [$context]);
                             break;
                         case 'InvalidRegistration':
                             $this->callback(EventsEnum::ON_PUSH_INVALID_REGISTRATION, [$context]);
                             break;
                         case 'NotRegistered':
                             $this->callback(EventsEnum::ON_PUSH_NOT_REGISTERED, [$context]);
                             break;
                     }
                     break;
             }
         }
     }
     return ['success' => $data['success'], 'failure' => $data['failure']];
 }
開發者ID:akentner,項目名稱:incoming-ftp,代碼行數:38,代碼來源:GoogleCloudMessaging.php

示例5: parse

 public function parse(Session $rets, ResponseInterface $response)
 {
     $xml = $response->xml();
     $base = $xml->METADATA->{'METADATA-SYSTEM'};
     $metadata = new \PHRETS\Models\Metadata\System();
     $metadata->setSession($rets);
     $configuration = $rets->getConfiguration();
     if ($configuration->getRetsVersion()->is1_5()) {
         if (isset($base->System->SystemID)) {
             $metadata->setSystemId((string) $base->System->SystemID);
         }
         if (isset($base->System->SystemDescription)) {
             $metadata->setSystemDescription((string) $base->System->SystemDescription);
         }
     } else {
         if (isset($base->SYSTEM->attributes()->SystemID)) {
             $metadata->setSystemId((string) $base->SYSTEM->attributes()->SystemID);
         }
         if (isset($base->SYSTEM->attributes()->SystemDescription)) {
             $metadata->setSystemDescription((string) $base->SYSTEM->attributes()->SystemDescription);
         }
         if (isset($base->SYSTEM->attributes()->TimeZoneOffset)) {
             $metadata->setTimezoneOffset((string) $base->SYSTEM->attributes()->TimeZoneOffset);
         }
     }
     if (isset($base->SYSTEM->Comments)) {
         $metadata->setComments((string) $base->SYSTEM->Comments);
     }
     if (isset($base->attributes()->Version)) {
         $metadata->setVersion((string) $xml->METADATA->{'METADATA-SYSTEM'}->attributes()->Version);
     }
     return $metadata;
 }
開發者ID:mitchlayzell,項目名稱:PHRETS,代碼行數:33,代碼來源:System.php

示例6: isNotJsonError

 private function isNotJsonError(HttpResponseInterface $httpResponse)
 {
     if ($httpResponse->getStatusCode() == ResponseInterface::HTTP_CODE_NOT_FOUND || $httpResponse->getStatusCode() == ResponseInterface::HTTP_CODE_INTERNAL_SERVER_ERROR || $httpResponse->getStatusCode() == ResponseInterface::HTTP_CODE_METHOD_NOT_ALLOWED) {
         return true;
     }
     return false;
 }
開發者ID:boylen,項目名稱:virgil-php-keys,代碼行數:7,代碼來源:Connection.php

示例7: it_handle_unexpected_oboom_response

 public function it_handle_unexpected_oboom_response(Client $guzzleClient, ResponseInterface $response)
 {
     $url = 'http://example.com';
     $response->json()->shouldBeCalled()->willReturn([400]);
     $guzzleClient->get($url, ['query' => []])->willReturn($response);
     $this->shouldThrow(new RuntimeException('API error', 400))->during('call', [$url]);
 }
開發者ID:vantoozz,項目名稱:oboom-php-sdk,代碼行數:7,代碼來源:GuzzleTransportSpec.php

示例8: __construct

 /**
  * Creates a response object
  * @param ResponseInterface $responseInterface
  * @throws ParseException
  */
 public function __construct(ResponseInterface $responseInterface)
 {
     $this->response = $responseInterface->json();
     $this->status = isset($this->response['meta']['code']) ? $this->response['meta']['code'] : 500;
     $this->errorCode = isset($this->response['meta']['error_code']) ? $this->response['meta']['error_code'] : null;
     $this->responseErrorCodes = new ResponseErrorCodes();
 }
開發者ID:credibility,項目名稱:dandb,代碼行數:12,代碼來源:Response.php

示例9:

 function it_should_make_post_request(ResponseInterface $responce)
 {
     $responce->getHeader("Content-Type")->willReturn('blablaxmlblabla');
     $responce->getBody()->willReturn('<xml></xml>');
     $this->client->post(Argument::any(), Argument::any())->willReturn($responce);
     $responce->xml()->willReturn(new \SimpleXMLElement('<xml></xml>'));
     $this->post(Argument::type('string'))->shouldBeAnInstanceOf('Bxav\\Component\\ResellerClub\\Model\\XmlResponse');
 }
開發者ID:bxav,項目名稱:service_handler,代碼行數:8,代碼來源:ResellerClubClientSpec.php

示例10: __construct

 /**
  * Sets attributes from response xml.
  *
  * @param ResponseInterface $response
  * @param array $attributes
  */
 public function __construct(ResponseInterface $response, array $attributes = null)
 {
     $this->response = $response;
     if (is_null($attributes)) {
         $attributes = Xml::elementsToArray($response->xml()->xpath('/RESPONSE/FIELDS/*'));
     }
     parent::__construct($attributes);
 }
開發者ID:RDelorier,項目名稱:first-americam-xml,代碼行數:14,代碼來源:Response.php

示例11: setResponse

 /**
  * Set Http response in case of successful request
  * 
  * @param GuzzleHttp\Message\ResponseInterface $response
  * @return CurrencyExchange\HttpClient
  * @throws CurrencyExchange\Exception\ResponseException
  */
 public function setResponse(ResponseInterface $response)
 {
     if ($response->getStatusCode() != 200) {
         throw new ResponseException('Unsuccessful HTTP request: ' . $response->getStatusCode() . ' on ' . $this->getUri());
     }
     $this->_response = $response;
     return $this;
 }
開發者ID:teknoman,項目名稱:currency-exchange,代碼行數:15,代碼來源:Client.php

示例12: __construct

 /**
  * @param ResponseInterface $response raw json response
  * @param bool              $throw    Should throw API errors as exceptions
  *
  * @throws \Exception
  */
 public function __construct(ResponseInterface $response = null, $throw = true)
 {
     if ($response !== null) {
         $this->_executionTime = $response->getHeader('X-Execution-Time');
         $this->_callTime = $response->getHeader('X-Call-Time');
         $this->readJson((string) $response->getBody(), $throw);
     }
 }
開發者ID:jdi,項目名稱:tntaffiliate,代碼行數:14,代碼來源:ApiResult.php

示例13: getCount

 public function getCount($content, ResponseInterface $response = null)
 {
     $data = $response->json();
     if (empty($data)) {
         return false;
     }
     return (int) array_shift($data)['shares'];
 }
開發者ID:xdimedrolx,項目名稱:shares,代碼行數:8,代碼來源:MailRu.php

示例14: formatHeaders

 /**
  * @param RequestInterface|ResponseInterface $message
  * @return string
  */
 protected function formatHeaders($message)
 {
     $headers = [];
     foreach ($message->getHeaders() as $header => $value) {
         $headers[] = sprintf('%s: %s', $header, implode("\n  : ", $value));
     }
     return implode("\n", $headers);
 }
開發者ID:glooby,項目名稱:debug-bundle,代碼行數:12,代碼來源:AbstractMessageFormatter.php

示例15: parseHeaders

 private function parseHeaders(ResponseInterface $response, array &$data)
 {
     $data['message'] = $response->getStatusCode() . ' ' . $response->getReasonPhrase();
     if ($requestId = $response->getHeader('x-amz-request-id')) {
         $data['request_id'] = $requestId;
         $data['message'] .= " (Request-ID: {$requestId})";
     }
 }
開發者ID:briareos,項目名稱:aws-sdk-php,代碼行數:8,代碼來源:XmlErrorParser.php


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