當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。