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


PHP Uri::withQueryValue方法代码示例

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


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

示例1: __invoke

 /**
  * @param RequestInterface $request
  * @return RequestInterface
  */
 public function __invoke(RequestInterface $request)
 {
     foreach ($this->params as $param => $value) {
         $request = $request->withUri(Uri::withQueryValue($request->getUri(), $param, $value));
     }
     return $request;
 }
开发者ID:emarref,项目名称:guzzle-param-middleware,代码行数:11,代码来源:ParamMiddleware.php

示例2: appendQueryParams

 /**
  * @param RequestInterface $request
  *
  * @return RequestInterface
  */
 private function appendQueryParams(RequestInterface $request)
 {
     $queryParams = $this->auth->getQueryParameters();
     foreach ($queryParams as $key => $value) {
         $uri = Uri::withQueryValue($request->getUri(), $key, $value);
         $request = $request->withUri($uri);
     }
     return $request;
 }
开发者ID:adlogix,项目名称:guzzle-atlassian-connect-middleware,代码行数:14,代码来源:ConnectMiddleware.php

示例3: get

 public static function get(array $options, $key)
 {
     $stack = HandlerStack::create();
     $stack->unshift(Middleware::mapRequest(function (RequestInterface $request) use($key) {
         return $request->withUri(Uri::withQueryValue($request->getUri(), 'key', $key));
     }));
     $options['handler'] = $stack;
     return new Client($options);
 }
开发者ID:mcfedr,项目名称:youtubelivestreamsbundle,代码行数:9,代码来源:GuzzleClientFactory.php

示例4: research

 /**
  * @param RequestInterface $request
  *
  * @return ResponseInterface
  *
  * @throws ApiException | SearchLimitException
  */
 public function research(RequestInterface $request)
 {
     try {
         $response = $this->httpClient->request('GET', Uri::withQueryValue($request->getUri(), 'apikey', $this->apiKey));
         return new Response($response);
     } catch (\GuzzleHttp\Exception\ClientException $ex) {
         throw ExceptionFactory::createThrowable($ex);
     }
 }
开发者ID:spalax,项目名称:keywordtool-client,代码行数:16,代码来源:Client.php

示例5: __invoke

 /**
  * {@inheritDoc}
  */
 public function __invoke(RequestInterface $request, array $options)
 {
     $next = $this->nextHandler;
     if (!$this->config->has('access_token') || $this->config->get('access_token') === null) {
         return $next($request, $options);
     }
     $uri = Uri::withQueryValue($request->getUri(), 'access_token', $this->config->get('access_token')->getToken());
     return parent::__invoke($request->withUri($uri)->withHeader('Content-Type', 'application/json'), $options);
 }
开发者ID:larabros,项目名称:elogram,代码行数:12,代码来源:AuthMiddleware.php

示例6: makeUri

 /**
  * @param $url
  * @param array $params
  *
  * @return \Psr\Http\Message\UriInterface
  */
 private function makeUri($url, $params = array())
 {
     $uri = \GuzzleHttp\uri_template($this->endpoint, array_merge($this->defaults, $params));
     $uri = new Psr7\Uri($uri);
     // All arguments must be urlencoded (as per RFC 1738).
     $query = Psr7\build_query($params, PHP_QUERY_RFC1738);
     $uri = $uri->withQuery($query);
     return Psr7\Uri::withQueryValue($uri, 'url', $url);
 }
开发者ID:bangpound,项目名称:oembed,代码行数:15,代码来源:StandardProvider.php

示例7: __invoke

 /**
  * Inject credentials information into the query parameters
  *
  * @param RequestInterface $request
  * @param array            $options
  *
  * @return GuzzleResponseInterface
  */
 public function __invoke(RequestInterface $request, array $options)
 {
     if ($request->getUri()->getScheme() == 'https' && $options['auth'] == static::AUTH_NAME) {
         $uri = Uri::withQueryValue($request->getUri(), 'client_id', $this->userKey ?: $this->apiKey);
         $uri = Uri::withQueryValue($uri, 'client_secret', $this->secret);
         $request = $request->withUri($uri);
     }
     $fn = $this->nextHandler;
     return $fn($request, $options);
 }
开发者ID:graze,项目名称:gigya-client,代码行数:18,代码来源:CredentialsAuthMiddleware.php

示例8: __invoke

 /**
  * {@inheritDoc}
  */
 public function __invoke(RequestInterface $request, array $options)
 {
     $next = $this->nextHandler;
     if (!$this->config->get('secure_requests')) {
         return $next($request, $options);
     }
     $uri = $request->getUri();
     $sig = $this->generateSig($this->getPath($uri), $this->getQueryParams($uri), $this->config->get('client_secret'));
     $uri = Uri::withQueryValue($uri, 'sig', $sig);
     return parent::__invoke($request->withUri($uri), $options);
 }
开发者ID:larabros,项目名称:elogram,代码行数:14,代码来源:SecureRequestMiddleware.php

示例9: invoke_QueryParameters_Success

 /**
  * @test
  */
 public function invoke_QueryParameters_Success()
 {
     $this->auth->expects($this->once())->method('getHeaders')->willReturn([]);
     $this->auth->expects($this->once())->method('getQueryParameters')->willReturn(['jwt' => 'YYYY', 'otherParam' => 'YYYY']);
     $this->request->expects($this->exactly(3))->method('getUri')->willReturn($this->uri);
     $this->request->expects($this->exactly(2))->method('withUri')->withConsecutive(Uri::withQueryValue($this->uri, 'jwt', 'YYYY'), Uri::withQueryValue($this->uri, 'otherParam', 'YYYY'))->willReturnSelf();
     $middleware = new ConnectMiddleware($this->auth, $this->appContext);
     $callable = $middleware(function (RequestInterface $actualRequest, array $options) {
         $this->assertEquals($this->request, $actualRequest);
         $this->assertEquals(['Hello World'], $options);
     });
     $callable($this->request, ['Hello World']);
 }
开发者ID:adlogix,项目名称:guzzle-atlassian-connect-middleware,代码行数:16,代码来源:ConnectMiddlewareTest.php

示例10: connect

 /**
  * @return Client
  */
 protected function connect()
 {
     $base_uri = $this->config->get('base_uri');
     if ($this->config->has('transport') && $this->config->has('host') && $this->config->has('port')) {
         $base_uri = sprintf('%s://%s:%s', $this->config->get('transport'), $this->config->get('host'), $this->config->get('port'));
     }
     $client_options = ['base_uri' => $base_uri];
     if ($this->config->get('debug', false)) {
         $client_options['debug'] = true;
     }
     if ($this->config->has('auth')) {
         $auth = (array) $this->config->get('auth');
         if (!isset($auth['username'])) {
             throw new RuntimeError('Missing required "username" setting within given auth config.');
         }
         if (!isset($auth['password'])) {
             throw new RuntimeError('Missing required "password" setting within given auth config.');
         }
         $client_options['auth'] = [$auth['username'], $auth['password'], isset($auth['type']) ? $auth['type'] : 'basic'];
     }
     if ($this->config->has('default_headers')) {
         $client_options['headers'] = (array) $this->config->get('default_headers');
     }
     if ($this->config->has('default_options')) {
         $client_options = array_merge($client_options, (array) $this->config->get('default_options')->toArray());
     }
     if ($this->config->has('default_query')) {
         $handler = HandlerStack::create();
         $handler->push(Middleware::mapRequest(function (RequestInterface $request) {
             $uri = $request->getUri();
             foreach ((array) $this->config->get('default_query')->toArray() as $param => $value) {
                 $uri = Uri::withQueryValue($uri, $param, $value);
             }
             return $request->withUri($uri);
         }));
         $client_options['handler'] = $handler;
     }
     return new Client($client_options);
 }
开发者ID:honeybee,项目名称:honeybee,代码行数:42,代码来源:GuzzleConnector.php

示例11: attachAccessToken

 /**
  * Set request access_token query.
  */
 protected function attachAccessToken()
 {
     if (!$this->accessToken) {
         return;
     }
     // log
     $this->getHttp()->addMiddleware(function (callable $handler) {
         return function (RequestInterface $request, array $options) use($handler) {
             $field = $this->accessToken->getQueryName();
             $token = $this->accessToken->getToken();
             $request = $request->withUri(Uri::withQueryValue($request->getUri(), $field, $token));
             Log::debug("Request Token: {$token}");
             Log::debug('Request Uri: ' . $request->getUri());
             return $handler($request, $options);
         };
     });
     // retry
     $this->getHttp()->addMiddleware(Middleware::retry(function ($retries, RequestInterface $request, ResponseInterface $response = null, RequestException $exception = null) {
         // Limit the number of retries to 2
         if ($retries <= 2 && $response && ($body = $response->getBody())) {
             // Retry on server errors
             if (stripos($body, 'errcode') && (stripos($body, '40001') || stripos($body, '42001'))) {
                 return true;
             }
         }
         return false;
     }));
 }
开发者ID:Rongx,项目名称:demo_wechat,代码行数:31,代码来源:AbstractAPI.php

示例12: readStreamFeed

 /**
  * @param  string                            $streamUrl
  * @param  EntryEmbedMode                    $embedMode
  * @return StreamFeed
  * @throws Exception\StreamDeletedException
  * @throws Exception\StreamNotFoundException
  */
 private function readStreamFeed($streamUrl, EntryEmbedMode $embedMode = null)
 {
     $request = $this->getJsonRequest($streamUrl);
     if ($embedMode != null && $embedMode != EntryEmbedMode::NONE()) {
         $uri = Uri::withQueryValue($request->getUri(), 'embed', $embedMode->toNative());
         $request = $request->withUri($uri);
     }
     $this->sendRequest($request);
     $this->ensureStatusCodeIsGood($streamUrl);
     return new StreamFeed($this->lastResponseAsJson(), $embedMode);
 }
开发者ID:robertlemke,项目名称:php-eventstore-client,代码行数:18,代码来源:EventStore.php

示例13: configureAuthenticationHandler

 private function configureAuthenticationHandler(HandlerStack $handlerStack)
 {
     $token = $this->token;
     $handlerStack->remove('wechatClient:authentication');
     $handlerStack->unshift(function (callable $handler) use($token) {
         return function (RequestInterface $request, array $options = []) use($handler, $token) {
             if ($token) {
                 $newUri = Uri::withQueryValue($request->getUri(), 'access_token', $token->value());
                 $request = $request->withUri($newUri);
             }
             return $handler($request, $options);
         };
     }, 'wechatClient:authentication');
 }
开发者ID:garbetjie,项目名称:wechat,代码行数:14,代码来源:Client.php

示例14: createRequest

 /**
  * Creates a new Request to this Endpoint.
  *
  * @param string[] $query
  * @param null     $url
  * @param string   $method
  * @param array    $options
  * @return RequestInterface
  */
 protected function createRequest(array $query = [], $url = null, $method = 'GET', $options = [])
 {
     $url = !is_null($url) ? $url : $this->url();
     $uri = new Uri($url);
     foreach ($query as $key => $value) {
         $uri = Uri::withQueryValue($uri, $key, $value);
     }
     return new Request($method, $uri, $options);
 }
开发者ID:gw2treasures,项目名称:gw2api,代码行数:18,代码来源:Endpoint.php

示例15: httpGet

 /**
  * Performs a GET against the API.
  *
  * @param string $path
  * @param array  $query
  *
  * @return ResponseInterface
  * @throw Exception\PostcodeException | Exception\ApiException | Exception\UnexpectedValueException
  */
 private function httpGet($path, array $query = array())
 {
     $url = new Uri($this->baseUrl . $path);
     foreach ($query as $name => $value) {
         $url = Uri::withQueryValue($url, $name, $value);
     }
     //---
     $request = new Request('GET', $url, $this->buildHeaders());
     try {
         $response = $this->getHttpClient()->sendRequest($request);
     } catch (\RuntimeException $e) {
         throw new Exception\PostcodeException($e->getMessage(), $e->getCode(), $e);
     }
     //---
     if ($response->getStatusCode() != 200) {
         throw $this->createErrorException($response);
     }
     return $response;
 }
开发者ID:ministryofjustice,项目名称:postcodeinfo-client-php,代码行数:28,代码来源:Client.php


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