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


PHP RequestInterface::setQuery方法代码示例

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


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

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

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

示例3: getSignature

 /**
  * Calculate signature for request
  *
  * @param RequestInterface $request Request to generate a signature for
  *
  * @return string
  *
  * @throws \RuntimeException
  */
 public function getSignature(RequestInterface $request)
 {
     // For POST|PUT set the JSON body string as the params
     if ($request->getMethod() == 'POST' || $request->getMethod() == 'PUT') {
         $params = $request->getBody()->__toString();
         // Make sure to remove any other query params
         $request->setQuery([]);
     } else {
         $params = Query::fromString($request->getQuery(), Query::RFC1738)->toArray();
         $params = $this->prepareParameters($params);
         // Re-Set the query to the properly ordered query string
         $request->setQuery($params);
         $request->getQuery()->setEncodingType(Query::RFC1738);
     }
     $baseString = $this->createBaseString($request, $params);
     return base64_encode($this->sign_HMAC_SHA256($baseString));
 }
开发者ID:sonnygauran,项目名称:ticketevolution-php,代码行数:26,代码来源:TEvoAuth.php

示例4: add_query

 private function add_query(RequestInterface $request, $value)
 {
     if ($value instanceof Query) {
         $original = $request->getQuery();
         // Do not overwrite existing query string variables by overwriting
         // the object with the query string data passed in the URL
         $request->setQuery($value->overwriteWith($original->toArray()));
     } elseif (is_array($value)) {
         // Do not overwrite existing query string variables
         $query = $request->getQuery();
         foreach ($value as $k => $v) {
             if (!isset($query[$k])) {
                 $query[$k] = $v;
             }
         }
     } else {
         throw new \InvalidArgumentException('query value must be an array ' . 'or Query object');
     }
 }
开发者ID:hilmysyarif,项目名称:sic,代码行数:19,代码来源:MessageFactory.php

示例5: send

 /**
  * Set HTTP request to activeCollab API
  * @param RequestInterface $request
  * @param bool $authenticate
  * @return object
  * @throws Exception\ApiException
  * @throws Exception\AuthenticationFailedException
  */
 public function send(RequestInterface $request, $authenticate = true)
 {
     $request->addHeader('Accept', 'application/json');
     if ($authenticate) {
         $request->setQuery($request->getQuery()->set('auth_api_token', $this->api_token));
     }
     /** @var ResponseInterface $response */
     $response = $this->client->send($request);
     if ($response->getStatusCode() < 200 || $response->getStatusCode() >= 300) {
         switch ($response->getStatusCode()) {
             case 403:
                 throw new AuthenticationFailedException($response);
             default:
                 throw new ApiException($response);
         }
     }
     return $this->parseResponse($request, $response);
 }
开发者ID:NaszvadiG,项目名称:activecollab-api,代码行数:26,代码来源:BaseApiClient.php

示例6: getSignature

 /**
  * Calculate signature for request
  *
  * @param RequestInterface $request Request to generate a signature for
  *
  * @return string
  */
 public function getSignature(RequestInterface $request)
 {
     // For POST|PUT set the JSON body string as the params
     if ($request->getMethod() == 'POST' || $request->getMethod() == 'PUT') {
         $params = $request->getBody()->__toString();
         /**
          * If you don't seek() back to the beginning then attempting to
          * send a JSON body > 1MB will probably fail.
          *
          * @link http://stackoverflow.com/q/32359664/99071
          * @link https://groups.google.com/forum/#!topic/guzzle/vkF5druf6AY
          */
         $request->getBody()->seek(0);
         // Make sure to remove any other query params
         $request->setQuery([]);
     } else {
         $params = Query::fromString($request->getQuery(), Query::RFC1738)->toArray();
         $params = $this->prepareParameters($params);
         // Re-Set the query to the properly ordered query string
         $request->setQuery($params);
         $request->getQuery()->setEncodingType(Query::RFC1738);
     }
     $baseString = $this->createBaseString($request, $params);
     return base64_encode($this->sign_HMAC_SHA256($baseString));
 }
开发者ID:ticketevolution,项目名称:ticketevolution-php,代码行数:32,代码来源:TEvoAuth.php

示例7: withQuery

 public function withQuery(Query $query)
 {
     $this->expectedRequest->setQuery($query);
     return $this;
 }
开发者ID:lezhnev74,项目名称:GuzzleHttpMock,代码行数:5,代码来源:RequestExpectation.php


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