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


PHP RequestInterface::getQuery方法代码示例

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


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

示例1: send

 /**
  * {@inheritdoc}
  *
  * @return array
  */
 public function send(RequestInterface $request)
 {
     // Disable HTTP error codes unless requested so that we can parse out
     // the errors ourselves.
     if (!$request->getQuery()->hasKey('httpError')) {
         $request->getQuery()->set('httpError', 'false');
     }
     $response = parent::send($request);
     // Parse out exceptions from the response body.
     $contentType = $response->getHeader('Content-Type');
     if (preg_match('~^(application|text)/json~', $contentType)) {
         // @todo Figure out how we can support the big_int_string option here.
         // @see http://stackoverflow.com/questions/19520487/json-bigint-as-string-removed-in-php-5-5
         $data = $response->json();
         if (!empty($data['responseCode']) && !empty($data['isException'])) {
             throw new ApiException("Error {$data['title']} on request to {$request->getUrl()}: {$data['description']}", (int) $data['responseCode']);
         } elseif (!empty($data[0]['entry']['responseCode']) && !empty($data[0]['entry']['isException'])) {
             throw new ApiException("Error {$data[0]['entry']['title']} on request to {$request->getUrl()}: {$data[0]['entry']['description']}", (int) $data[0]['entry']['responseCode']);
         }
         return $data;
     } elseif (preg_match('~^(application|text)/(atom\\+)?xml~', $contentType)) {
         if (strpos((string) $response->getBody(), 'xmlns:e="http://xml.theplatform.com/exception"') !== FALSE) {
             if (preg_match('~<e:title>(.+)</e:title><e:description>(.+)</e:description><e:responseCode>(.+)</e:responseCode>~', (string) $response->getBody(), $matches)) {
                 throw new ApiException("Error {$matches[1]} on request to {$request->getUrl()}: {$matches[2]}", (int) $matches[3]);
             } elseif (preg_match('~<title>(.+)</title><summary>(.+)</summary><e:responseCode>(.+)</e:responseCode>~', (string) $response->getBody(), $matches)) {
                 throw new ApiException("Error {$matches[1]} on request to {$request->getUrl()}: {$matches[2]}", (int) $matches[3]);
             }
         }
         $data = $response->xml();
         $data = array($data->getName() => static::convertXmlToArray($data));
         return $data;
     } else {
         throw new ParseException("Unable to handle response with type {$contentType}.", $response);
     }
 }
开发者ID:lullabot,项目名称:mpx-php,代码行数:40,代码来源:Client.php

示例2: getRequestAndQuery

 /**
  * @param RequestInterface $request
  * @return array ['query' => ..., 'request' => ...]
  */
 protected function getRequestAndQuery(RequestInterface $request)
 {
     $query = [];
     foreach ($request->getQuery() as $param => $val) {
         $query[$param] = $val;
     }
     $requestInfo = ['url' => $request->getUrl(), 'path' => $request->getPath(), 'queryString' => (string) $request->getQuery(), 'method' => $request->getMethod(), 'hostname' => $request->getHost(), 'port' => $request->getPort(), 'resource' => $request->getResource()];
     return ['query' => $query, 'request' => $requestInfo];
 }
开发者ID:keboola,项目名称:generic-extractor,代码行数:13,代码来源:AbstractSignature.php

示例3: setRequestParams

 /**
  * 
  * @param RequestInterface $request
  * @param array $params
  */
 protected function setRequestParams(RequestInterface $request, $params = array())
 {
     $query = $request->getQuery();
     foreach ($params as $param) {
         $query->set(key($param), current($param));
     }
 }
开发者ID:adurolms,项目名称:tincan,代码行数:12,代码来源:LRSRepository.php

示例4: 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

示例5: buildRequest

 public function buildRequest(GuzzleRequestInterface $request)
 {
     if (!$this->query) {
         throw new \UnexpectedValueException(sprintf('CharacterSearchRequest requires at least a search query.'));
     }
     $query = $request->getQuery();
     $query->set('q', $this->getQuery());
     if ($this->getClass()) {
         $query->set('classjob', $this->getClass());
     }
     if ($this->getWorld()) {
         $query->set('worldname', $this->getWorld());
     }
     if ($this->getRace()) {
         $query->set('race_tribe', $this->getRace());
     }
     if ($this->getGrandCompanies()) {
         $query->set('gcid', $this->getGrandCompanies());
     }
     if ($this->getLanguages()) {
         $query->set('blog_lang', $this->getLanguages());
     }
     if ($this->getPage()) {
         $query->set('page', $this->getPage());
     }
     if ($this->getOrder()) {
         $query->set('order', $this->getOrder());
     } else {
         $query->set('order', static::ORDER_NAME_ASC);
     }
 }
开发者ID:ghassani,项目名称:xiv-lodestone-php-api,代码行数:31,代码来源:CharacterSearchRequest.php

示例6: after

 public function after(CommandInterface $command, RequestInterface $request, Operation $operation, array $context)
 {
     $additional = $operation->getAdditionalParameters();
     if ($additional && $additional->getLocation() == $this->locationName) {
         foreach ($command->toArray() as $key => $value) {
             if (!$operation->hasParam($key)) {
                 $request->getQuery()[$key] = $this->prepareValue($value, $additional);
             }
         }
     }
 }
开发者ID:ryanwinchester-forks,项目名称:guzzle-services,代码行数:11,代码来源:QueryLocation.php

示例7: signRequest

 /**
  * Signs the specified request with an SellerCenter API signing protocol by using the
  * provided SellerCenter API credentials and adding the required headers to the request
  *
  * @param RequestInterface     $request     Request to add a signature to
  * @param CredentialsInterface $credentials Signing credentials
  */
 public function signRequest(RequestInterface $request, CredentialsInterface $credentials)
 {
     $parameters = $request->getQuery()->toArray();
     $parameters['UserID'] = $credentials->getId();
     $parameters['Version'] = '1.0';
     $parameters['Action'] = $request->getConfig()->get('command')->getName();
     $parameters['Timestamp'] = gmdate(DateTime::ISO8601);
     // the keys MUST be in alphabetical order to correct signature calculation
     ksort($parameters);
     $parameters['Signature'] = rawurlencode(hash_hmac('sha256', http_build_query($parameters, '', '&', PHP_QUERY_RFC3986), $credentials->getKey(), false));
     $request->setQuery($parameters);
 }
开发者ID:danielcosta,项目名称:sellercenter-sdk,代码行数:19,代码来源:SignatureV1.php

示例8: buildRequest

 public function buildRequest(GuzzleRequestInterface $request)
 {
     if (!$this->id) {
         throw new \UnexpectedValueException(sprintf('FreeCompanyMemberListRequest requires a free company ID.'));
     }
     $query = $request->getQuery();
     if ($this->getOrder()) {
         $query->set('order', $this->getOrder());
     } else {
         $query->set('order', static::ORDER_NAME_ASC);
     }
 }
开发者ID:ghassani,项目名称:xiv-lodestone-php-api,代码行数:12,代码来源:FreeCompanyMemberListRequest.php

示例9: clientCall

 protected function clientCall($path, $method = 'GET', $data = array())
 {
     if ($this->request instanceof RequestInterface) {
         $this->request = $this->client->createRequest($method);
     }
     $this->request->setPath($path);
     $this->request->setMethod($method);
     $this->request->setQuery($data);
     if (isset($this->accessToken)) {
         $this->request->getQuery()->set('access_token', $this->accessToken);
     }
     $response = $this->client->send($this->request);
     return $response->json();
 }
开发者ID:gpascual,项目名称:deezer-sdk-php,代码行数:14,代码来源:DeezerClient.php

示例10: getSignature

 /**
  * Calculate signature for request
  *
  * This method mostly copy pasted from original class, except its bottom part where we actually hashing our request
  *
  * @param RequestInterface $request Request to generate a signature for
  * @param array $params Oauth parameters.
  *
  * @return string
  */
 public function getSignature(RequestInterface $request, array $params)
 {
     // Remove oauth_signature if present
     // Ref: Spec: 9.1.1 ("The oauth_signature parameter MUST be excluded.")
     unset($params['oauth_signature']);
     // Add POST fields if the request uses POST fields and no files
     $body = $request->getBody();
     if ($body instanceof PostBodyInterface && !$body->getFiles()) {
         $query = Query::fromString($body->getFields(true));
         $params += $query->toArray();
     }
     // Parse & add query string parameters as base string parameters
     $query = Query::fromString((string) $request->getQuery());
     $query->setEncodingType(Query::RFC1738);
     $params += $query->toArray();
     $baseString = $this->createBaseString($request, $this->prepareParameters($params));
     // changed code
     return base64_encode(hash_hmac('sha1', $baseString, $this->consumer_secret, true));
 }
开发者ID:mac2000,项目名称:woo-commerce-api-client,代码行数:29,代码来源:WooAuth1.php

示例11: deEncodeRequestUrl

 /**
  * 
  * @param HttpRequest $request
  * @return HttpRequest
  */
 private function deEncodeRequestUrl(HttpRequest $request)
 {
     $request->getQuery()->setEncodingType(false);
     return $request;
 }
开发者ID:webignition,项目名称:web-resource-service,代码行数:10,代码来源:Service.php

示例12: 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();
     // retry strategy
     if (intVal($code) >= 300) {
         $errors = null;
         $result = $response->json();
         // 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 raw response when "alt" is "media"
     if ($request && $request->getQuery()->get('alt') == 'media') {
         return $body;
     }
     return $response->json();
 }
开发者ID:rahul9878,项目名称:google-api-php-client,代码行数:28,代码来源:REST.php

示例13: moveHeadersToQuery

 private function moveHeadersToQuery(RequestInterface $request)
 {
     $query = $request->getQuery();
     foreach ($request->getHeaders() as $name => $header) {
         $name = strtolower($name);
         if (substr($name, 0, 5) == 'x-amz') {
             $query[$name] = $header;
         }
         if ($name !== 'host') {
             $request->removeHeader($name);
         }
     }
 }
开发者ID:briareos,项目名称:aws-sdk-php,代码行数:13,代码来源:SignatureV4.php

示例14: createCanonicalizedResource

 private function createCanonicalizedResource(RequestInterface $request)
 {
     $data = $this->parser->parse($request->getUrl());
     $buffer = '/';
     if ($data['bucket']) {
         $buffer .= $data['bucket'];
         if (!empty($data['key']) || !$data['path_style']) {
             $buffer .= '/' . $data['key'];
         }
     }
     // Add sub resource parameters
     $query = $request->getQuery();
     $first = true;
     foreach ($this->signableQueryString as $key) {
         if ($query->hasKey($key)) {
             $value = $query[$key];
             $buffer .= $first ? '?' : '&';
             $first = false;
             $buffer .= $key;
             // Don't add values for empty sub-resources
             if (strlen($value)) {
                 $buffer .= "={$value}";
             }
         }
     }
     return $buffer;
 }
开发者ID:briareos,项目名称:aws-sdk-php,代码行数:27,代码来源:S3Signature.php

示例15: getSignature

 /**
  * Calculate signature for request
  *
  * @param RequestInterface $request Request to generate a signature for
  * @param array            $params  Oauth parameters.
  *
  * @return string
  *
  * @throws \RuntimeException
  */
 public function getSignature(RequestInterface $request, array $params)
 {
     // Remove oauth_signature if present
     // Ref: Spec: 9.1.1 ("The oauth_signature parameter MUST be excluded.")
     unset($params['oauth_signature']);
     // Add POST fields if the request uses POST fields and no files
     $body = $request->getBody();
     if ($body instanceof PostBodyInterface && !$body->getFiles()) {
         $query = Query::fromString($body->getFields(true));
         $params += $query->toArray();
     }
     // Parse & add query string parameters as base string parameters
     $query = Query::fromString((string) $request->getQuery());
     $query->setEncodingType(Query::RFC1738);
     $params += $query->toArray();
     $baseString = $this->createBaseString($request, $this->prepareParameters($params));
     // Implements double-dispatch to sign requests
     switch ($this->config['signature_method']) {
         case Oauth1::SIGNATURE_METHOD_HMAC:
             $signature = $this->signUsingHmacSha1($baseString);
             break;
         case Oauth1::SIGNATURE_METHOD_RSA:
             $signature = $this->signUsingRsaSha1($baseString);
             break;
         case Oauth1::SIGNATURE_METHOD_PLAINTEXT:
             $signature = $this->signUsingPlaintext($baseString);
             break;
         default:
             throw new \RuntimeException('Unknown signature method: ' . $this->config['signature_method']);
             break;
     }
     return base64_encode($signature);
 }
开发者ID:bslinger,项目名称:oauth-subscriber,代码行数:43,代码来源:Oauth1.php


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