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


PHP RequestInterface::getQuery方法代码示例

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


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

示例1: signRequest

 /**
  * @param RequestInterface|EntityEnclosingRequestInterface $request
  * @param Credentials $credentials
  */
 public function signRequest($request, $credentials)
 {
     $request->setHeader('X-HMB-Signature-Method', self::DEFAULT_METHOD);
     $request->setHeader('X-HMB-Signature-Version', self::DEFAULT_SIGN_VERSION);
     $request->setHeader('X-HMB-TimeStamp', time());
     $contentMd5 = $request instanceof EntityEnclosingRequestInterface ? md5($request->getBody()) : '';
     if ($contentMd5) {
         $request->setHeader('Content-MD5', $contentMd5);
     }
     $sign = array();
     $sign[] = strtoupper($request->getMethod());
     $sign[] = $request->getHost();
     if ($request->getHeader('Content-MD5')) {
         $sign[] = $request->getHeader('Content-MD5');
     }
     if ($request->getHeader('Content-Type')) {
         $sign[] = $request->getHeader('Content-Type');
     }
     $sign[] = $request->getHeader('X-HMB-Signature-Method');
     $sign[] = $request->getHeader('X-HMB-Signature-Version');
     $sign[] = $request->getHeader('X-HMB-TimeStamp');
     if ($request->getHeader('X-HMB-User-Session-Token')) {
         $sign[] = $request->getHeader('X-HMB-User-Session-Token');
     }
     $sign[] = $request->getQuery(true) ? $request->getPath() . '?' . $request->getQuery(true) : $request->getPath();
     $signature = base64_encode(hash_hmac(strtolower($request->getHeader('X-HMB-Signature-Method')), implode("\n", $sign), $credentials->getSecret()));
     $request->setHeader('Authorization', sprintf('%s %s:%s', self::AUTHORIZATION_SCHME, $credentials->getKey(), $signature));
 }
开发者ID:sonicmoov,项目名称:hmb-sdk-php,代码行数:32,代码来源:Signature.php

示例2: addQueryString

 private function addQueryString(array $queryString, RequestInterface $request)
 {
     ksort($queryString);
     foreach ($queryString as $key => $value) {
         $request->getQuery()->set($key, $value);
     }
 }
开发者ID:CHANDRA-BHUSHAN-SAH,项目名称:stormpath-sdk-php,代码行数:7,代码来源:HttpClientRequestExecutor.php

示例3: onOpen

 /**
  * {@inheritdoc}
  * @throws \UnexpectedValueException If a controller is not \Ratchet\Http\HttpServerInterface
  */
 public function onOpen(ConnectionInterface $conn, RequestInterface $request = null)
 {
     if (null === $request) {
         throw new \UnexpectedValueException('$request can not be null');
     }
     $context = $this->_matcher->getContext();
     $context->setMethod($request->getMethod());
     $context->setHost($request->getHost());
     try {
         $route = $this->_matcher->match($request->getPath());
     } catch (MethodNotAllowedException $nae) {
         return $this->close($conn, 403);
     } catch (ResourceNotFoundException $nfe) {
         return $this->close($conn, 404);
     }
     if (is_string($route['_controller']) && class_exists($route['_controller'])) {
         $route['_controller'] = new $route['_controller']();
     }
     if (!$route['_controller'] instanceof HttpServerInterface) {
         throw new \UnexpectedValueException('All routes must implement Ratchet\\Http\\HttpServerInterface');
     }
     $parameters = array();
     foreach ($route as $key => $value) {
         if (is_string($key) && '_' !== substr($key, 0, 1)) {
             $parameters[$key] = $value;
         }
     }
     $parameters = array_merge($parameters, $request->getQuery()->getAll());
     $url = Url::factory($request->getPath());
     $url->setQuery($parameters);
     $request->setUrl($url);
     $conn->controller = $route['_controller'];
     $conn->controller->onOpen($conn, $request);
 }
开发者ID:DannyHuisman,项目名称:Ratchet,代码行数:38,代码来源:Router.php

示例4: signRequest

 /**
  * Sign the Pusher request
  *
  * @link  http://pusher.com/docs/rest_api#authentication
  * @param RequestInterface $request
  * @param Credentials $credentials
  */
 public function signRequest(RequestInterface $request, Credentials $credentials)
 {
     $queryParameters = array('auth_key' => $credentials->getKey(), 'auth_timestamp' => time(), 'auth_version' => self::AUTH_VERSION);
     if ($request instanceof EntityEnclosingRequestInterface) {
         $body = $request->getBody();
         $queryParameters['body_md5'] = $body->getContentLength() ? $body->getContentMd5() : '';
     }
     // The signature algorithm asks that keys are all lowercased
     $queryParameters = array_change_key_case($request->getQuery()->toArray()) + $queryParameters;
     $queryParameters = array_filter($queryParameters);
     ksort($queryParameters);
     $method = strtoupper($request->getMethod());
     $requestPath = $request->getPath();
     $query = urldecode(http_build_query($queryParameters));
     $signature = $this->signString(implode("\n", array($method, $requestPath, $query)), $credentials);
     $queryParameters['auth_signature'] = $signature;
     $request->getQuery()->replace($queryParameters);
 }
开发者ID:GedConk,项目名称:zfr-pusher,代码行数:25,代码来源:PusherSignature.php

示例5: getParamsToSign

 public function getParamsToSign(RequestInterface $request, $timestamp, $nonce)
 {
     $params = $this->getOauthParams($timestamp, $nonce);
     $params->merge($request->getQuery());
     if ($this->shouldPostFieldsBeSigned($request)) {
         $params->merge($request->getPostFields());
     }
     $params = $params->toArray();
     ksort($params);
     return $params;
 }
开发者ID:Ryu0621,项目名称:SaNaVi,代码行数:11,代码来源:OauthPlugin.php

示例6: onCommand

 public function onCommand(RequestInterface $request)
 {
     $applicationName = $request->getQuery()->get('app');
     $module = $request->getQuery()->get('module');
     if (!$module) {
         $module = 'index';
     }
     try {
         $application = $this->applications->get($applicationName);
         $this->get('event_dispatcher')->dispatch($application->getName() . '.state.activate', new InteractionEvent($request));
         $this->get('event_dispatcher')->dispatch($this->currentApplication->getName() . '.state.deactivate', new InteractionEvent($request));
         $this->get('server.web_socket')->switchApp($applicationName, $module);
         $this->currentApplication = $application;
         $this->currentModule = $module;
     } catch (ApplicationNotFoundException $e) {
         return $this->jsonResponse(404, 'This application does not exist.');
     } catch (ApplicationInitializationException $e) {
         return $this->jsonResponse(400, $e->getMessage());
     }
     return $this->jsonResponse(200, 'Application switched.');
 }
开发者ID:owlycode,项目名称:reactboard,代码行数:21,代码来源:CoreApplication.php

示例7: getCount

 /**
  * Get the issue count from the provided request.
  *
  *
  * @param array $request
  *   Guzzle request for the first page of results.
  * @return number
  *   The total number of issues for the search paramaters of the request.
  */
 public function getCount(\Guzzle\Http\Message\RequestInterface $request)
 {
     // Make sure page isn't set from a previous call on the same request object.
     $request->getQuery()->remove('page');
     $issueRowCount = 0;
     while (true) {
         $document = new DomCrawler\Crawler((string) $request->send()->getBody());
         $issueView = $document->filter('.view-project-issue-search-project-searchapi');
         $issueRowCount += $issueView->filter('table.views-table tbody tr')->reduce(function (DomCrawler\Crawler $element) {
             // Drupal.org is returning rows where all cells are empty,
             // which bumps up the count incorrectly.
             return $element->filter('td')->first()->filter('a')->count() > 0;
         })->count();
         $pagerNext = $issueView->filter('.pager-next a');
         if (!$pagerNext->count()) {
             break;
         }
         preg_match('/page=(\\d+)/', $pagerNext->attr('href'), $urlMatches);
         $request->getQuery()->set('page', (int) $urlMatches[1]);
     }
     return $issueRowCount;
 }
开发者ID:pingers,项目名称:drupalreleasedate,代码行数:31,代码来源:DrupalIssueCount.php

示例8: getCanonicalizedParameterString

 /**
  * Get the canonicalized query/parameter string for a request
  *
  * @param RequestInterface $request Request used to build canonicalized string
  *
  * @return string
  */
 public function getCanonicalizedParameterString(RequestInterface $request)
 {
     if ($request->getMethod() == 'POST') {
         $params = $request->getPostFields()->toArray();
     } else {
         $params = $request->getQuery()->toArray();
     }
     // Don't resign a previous signature value
     unset($params['Signature']);
     uksort($params, 'strcmp');
     $str = '';
     foreach ($params as $key => $val) {
         $str .= rawurlencode($key) . '=' . rawurlencode($val) . '&';
     }
     return substr($str, 0, -1);
 }
开发者ID:noahkim,项目名称:kowop,代码行数:23,代码来源:SignatureV2.php

示例9: __toString

 /**
  * Returns an HTML-formatted string representation of the exception.
  *
  * @return string
  * @internal
  */
 public function __toString()
 {
     $msg = $this->getMessage();
     if (is_object($this->requestObj) && $this->requestObj instanceof \Guzzle\Http\Message\Request) {
         $request = array('url' => $this->requestObj->getUrl(), 'host' => $this->requestObj->getHost(), 'headers' => $this->requestObj->getRawHeaders(), 'query' => (string) $this->requestObj->getQuery());
         if ($this->requestObj instanceof \Guzzle\Http\Message\EntityEnclosingRequestInterface) {
             $request_body = $this->requestObj->getBody();
             $request['content-type'] = $request_body->getContentType();
             $request['content-length'] = $request_body->getContentLength();
             $request['body'] = $request_body->__toString();
         }
         $msg .= "\n\nRequest: <pre>" . htmlspecialchars(print_r($request, true)) . '</pre>';
     }
     if (is_object($this->responseObj) && $this->responseObj instanceof \Guzzle\Http\Message\Response) {
         $response = array('status' => $this->responseObj->getStatusCode(), 'headers' => $this->responseObj->getRawHeaders(), 'body' => $this->responseBody);
         $msg .= "\n\nResponse: <pre>" . htmlspecialchars(print_r($response, true)) . '</pre>';
     }
     return $msg;
 }
开发者ID:nevetS,项目名称:flame,代码行数:25,代码来源:ResponseException.php

示例10: getCanonicalizedQueryString

 /**
  * Get the canonicalized query string for a request
  *
  * @param  RequestInterface $request
  * @return string
  */
 protected function getCanonicalizedQueryString(RequestInterface $request)
 {
     $queryParams = $request->getQuery()->getAll();
     unset($queryParams['X-Amz-Signature']);
     if (empty($queryParams)) {
         return '';
     }
     $qs = '';
     ksort($queryParams);
     foreach ($queryParams as $key => $values) {
         if (is_array($values)) {
             sort($values);
         } elseif (!$values) {
             $values = array('');
         }
         foreach ((array) $values as $value) {
             $qs .= rawurlencode($key) . '=' . rawurlencode($value) . '&';
         }
     }
     return substr($qs, 0, -1);
 }
开发者ID:claybbs,项目名称:namedmanager,代码行数:27,代码来源:AbstractSignature.php

示例11: getParamsToSign

 public function getParamsToSign(RequestInterface $request, $timestamp, $nonce)
 {
     $params = new Collection(array('oauth_consumer_key' => $this->config['consumer_key'], 'oauth_nonce' => $nonce, 'oauth_signature_method' => $this->config['signature_method'], 'oauth_timestamp' => $timestamp, 'oauth_version' => $this->config['version']));
     // Filter out oauth_token during temp token step, as in request_token.
     if ($this->config['token'] !== false) {
         $params->add('oauth_token', $this->config['token']);
     }
     // Add call back uri
     if (isset($this->config['callback_uri']) && !empty($this->config['callback_uri'])) {
         $params->add('oauth_callback', $this->config['callback_uri']);
     }
     // Add query string parameters
     $params->merge($request->getQuery());
     // Add POST fields to signing string
     if (!$this->config->get('disable_post_params') && $request instanceof EntityEnclosingRequestInterface && false !== strpos($request->getHeader('Content-Type'), 'application/x-www-form-urlencoded')) {
         $params->merge($request->getPostFields());
     }
     // Sort params
     $params = $params->getAll();
     ksort($params);
     return $params;
 }
开发者ID:vdmi,项目名称:guzzle-oauth,代码行数:22,代码来源:OauthPlugin.php

示例12: visit_query

protected function visit_query(RequestInterface $request, $value, $flags)
{
if (!is_array($value)) {
throw new InvalidArgumentException('query value must be an array');
}

if ($flags & self::OPTIONS_AS_DEFAULTS) {

 $query = $request->getQuery();
$query->overwriteWith(array_diff_key($value, $query->toArray()));
} else {
$request->getQuery()->overwriteWith($value);
}
}
开发者ID:Ryu0621,项目名称:SaNaVi,代码行数:14,代码来源:RequestFactory.php

示例13: getParamsToSign

 /**
  * Parameters sorted and filtered in order to properly sign a request
  *
  * @param RequestInterface $request   Request to generate a signature for
  * @param integer          $timestamp Timestamp to use for nonce
  * @param string           $nonce
  *
  * @return array
  */
 public function getParamsToSign(RequestInterface $request, $timestamp, $nonce)
 {
     $params = new Collection(array('oauth_consumer_key' => $this->config['consumer_key'], 'oauth_nonce' => $nonce, 'oauth_signature_method' => $this->config['signature_method'], 'oauth_timestamp' => $timestamp, 'oauth_token' => $this->config['token'], 'oauth_version' => $this->config['version']));
     if (array_key_exists('callback', $this->config) == true) {
         $params['oauth_callback'] = $this->config['callback'];
     }
     if (array_key_exists('verifier', $this->config) == true) {
         $params['oauth_verifier'] = $this->config['verifier'];
     }
     // Add query string parameters
     $params->merge($request->getQuery());
     // Add POST fields to signing string if required
     if ($this->shouldPostFieldsBeSigned($request)) {
         $params->merge($request->getPostFields());
     }
     // Sort params
     $params = $params->toArray();
     ksort($params);
     return $params;
 }
开发者ID:diandianxiyu,项目名称:Yii2Api,代码行数:29,代码来源:OauthPlugin.php

示例14: visit

 /**
  * {@inheritdoc}
  */
 public function visit(CommandInterface $command, RequestInterface $request, $key, $value)
 {
     $request->getQuery()->set($key, $value);
 }
开发者ID:jsnshrmn,项目名称:Suma,代码行数:7,代码来源:QueryVisitor.php

示例15: moveHeadersToQuery

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


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