当前位置: 首页>>代码示例>>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;未经允许,请勿转载。