• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Message\ResponseInterface类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中GuzzleHttp\Message\ResponseInterface的典型用法代码示例。如果您正苦于以下问题:PHP ResponseInterface类的具体用法?PHP ResponseInterface怎么用?PHP ResponseInterface使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了ResponseInterface类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: visit

 public function visit(GuzzleCommandInterface $command, ResponseInterface $response, Parameter $param, &$result, array $context = array())
 {
     // Retrieving a single header by name
     $name = $param->getName();
     if ($header = $response->getHeader($param->getWireName())) {
         $result[$name] = $param->filter($header);
     }
 }
开发者ID:bobozhangshao,项目名称:HeartCare,代码行数:8,代码来源:HeaderLocation.php


示例17:

 function it_should_return_results_as_an_object(ClientInterface $client, ResponseInterface $response)
 {
     $params = 'key=' . $this->test_key . '&hero_id=12345&skill=2';
     $expectedUrl = $this->test_base_url . 'IDOTA2Match_570/GetMatchDetails/v001/?' . $params;
     $responseReturn = json_decode('{"result": {"status": 1, "num_results": 0, "total_results": 407, "results_remaining": 307} }');
     $response->json(['object' => true])->shouldBeCalled()->willReturn($responseReturn);
     $client->get($expectedUrl)->shouldBeCalled()->willReturn($response);
     $this->endpoint('IDOTA2Match_570/GetMatchDetails/v001')->options(['hero_id' => 12345, 'skill' => 2])->get()->shouldReturn($responseReturn);
 }
开发者ID:bdunn313,项目名称:phpdota,代码行数:9,代码来源:SteamApiCallerSpec.php


示例18: __invoke

 public function __invoke(ResponseInterface $response)
 {
     \SellerCenter\SDK\Common\AnnotationRegistry::registerAutoloadNamespace();
     if (count($response->xml()->xpath('/ErrorResponse'))) {
         $serializer = SerializerBuilder::create()->build();
         return $serializer->deserialize($response->xml()->asXML(), 'SellerCenter\\SDK\\Common\\Api\\Response\\Error\\ErrorResponse', 'xml');
     }
     return;
 }
开发者ID:danielcosta,项目名称:sellercenter-sdk,代码行数:9,代码来源:XmlErrorParser.php


示例19:

 function it_should_return_a_service_response_when_verifying_an_ipn_message(Client $httpClient, Message $message, ResponseInterface $response)
 {
     $response->getBody()->willReturn('foo');
     $httpClient->post(Argument::type('string'), Argument::type('array'))->willReturn($response);
     $message->getAll()->willReturn(['foo' => 'bar']);
     $response = $this->verifyIpnMessage($message);
     $response->shouldHaveType('Mdb\\PayPal\\Ipn\\ServiceResponse');
     $response->getBody()->shouldReturn('foo');
 }
开发者ID:bogarin,项目名称:paypal-ipn-listener,代码行数:9,代码来源:GuzzleServiceSpec.php


示例20: processResponse

 /**
  * @param \GuzzleHttp\Message\ResponseInterface $response
  * @return Language[]
  */
 public function processResponse(\GuzzleHttp\Message\ResponseInterface $response)
 {
     $xml = simplexml_load_string($response->getBody()->getContents());
     $languages = [];
     foreach ($xml->string as $language) {
         $languages[] = new Language($language);
     }
     return $languages;
 }
开发者ID:badams,项目名称:microsoft-translator,代码行数:13,代码来源:GetLanguagesForTranslate.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Promise\promise_for函数代码示例发布时间:2022-05-23
下一篇:
PHP Message\Response类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap