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


PHP Uri::getQuery方法代码示例

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


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

示例1: testAllowsFalseyUrlParts

 public function testAllowsFalseyUrlParts()
 {
     $url = new Uri('http://a:1/0?0#0');
     $this->assertSame('a', $url->getHost());
     $this->assertEquals(1, $url->getPort());
     $this->assertSame('/0', $url->getPath());
     $this->assertEquals('0', (string) $url->getQuery());
     $this->assertSame('0', $url->getFragment());
     $this->assertEquals('http://a:1/0?0#0', (string) $url);
     $url = new Uri('');
     $this->assertSame('', (string) $url);
     $url = new Uri('0');
     $this->assertSame('/0', (string) $url);
 }
开发者ID:alvarobfdev,项目名称:LaravelCore,代码行数:14,代码来源:UriTest.php

示例2: getSignedUrl

 /**
  * Create a signed Amazon CloudFront URL.
  *
  * Keep in mind that URLs meant for use in media/flash players may have
  * different requirements for URL formats (e.g. some require that the
  * extension be removed, some require the file name to be prefixed
  * - mp4:<path>, some require you to add "/cfx/st" into your URL).
  *
  * @param string              $url     URL to sign (can include query
  *                                     string string and wildcards)
  * @param string|integer|null $expires UTC Unix timestamp used when signing
  *                                     with a canned policy. Not required
  *                                     when passing a custom $policy.
  * @param string              $policy  JSON policy. Use this option when
  *                                     creating a signed URL for a custom
  *                                     policy.
  *
  * @return string The file URL with authentication parameters
  * @throws \InvalidArgumentException if the URL provided is invalid
  * @link http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/WorkingWithStreamingDistributions.html
  */
 public function getSignedUrl($url, $expires = null, $policy = null)
 {
     // Determine the scheme of the url
     $urlSections = explode('://', $url);
     if (count($urlSections) < 2) {
         throw new \InvalidArgumentException("Invalid URL: {$url}");
     }
     // Get the real scheme by removing wildcards from the scheme
     $scheme = str_replace('*', '', $urlSections[0]);
     $uri = new Uri($scheme . '://' . $urlSections[1]);
     $query = Psr7\parse_query($uri->getQuery(), PHP_QUERY_RFC3986);
     $signature = $this->signer->getSignature($this->createResource($scheme, (string) $uri), $expires, $policy);
     $uri = $uri->withQuery(http_build_query($query + $signature, null, '&', PHP_QUERY_RFC3986));
     return $scheme === 'rtmp' ? $this->createRtmpUrl($uri) : (string) $uri;
 }
开发者ID:AWSRandall,项目名称:aws-sdk-php,代码行数:36,代码来源:UrlSigner.php

示例3: assertUriEquals

 protected function assertUriEquals($expectedUri, $actualUri)
 {
     if (is_string($expectedUri)) {
         $expectedUri = new Psr7\Uri($expectedUri);
     }
     if (is_string($actualUri)) {
         $actualUri = new Psr7\Uri($actualUri);
     }
     $this->assertEquals($expectedUri->getScheme(), $actualUri->getScheme());
     $this->assertEquals($expectedUri->getPort(), $actualUri->getPort());
     $this->assertEquals($expectedUri->getHost(), $actualUri->getHost());
     $this->assertEquals($expectedUri->getPath(), $actualUri->getPath());
     $expectedQueryParts = Psr7\parse_query($expectedUri->getQuery());
     $actualQueryParts = Psr7\parse_query($actualUri->getQuery());
     $this->assertEquals($expectedQueryParts, $actualQueryParts);
 }
开发者ID:redefining,项目名称:rest-api-client,代码行数:16,代码来源:UriAssertions.php

示例4: baseString

 /**
  * Generate a base string for a HMAC-SHA1 signature
  * based on the given a url, method, and any parameters.
  *
  * @param Url    $url
  * @param string $method
  * @param array  $parameters
  *
  * @return string
  */
 protected function baseString(Uri $url, $method = 'POST', array $parameters = array())
 {
     $baseString = rawurlencode($method) . '&';
     $schemeHostPath = Uri::fromParts(array('scheme' => $url->getScheme(), 'host' => $url->getHost(), 'path' => $url->getPath()));
     $baseString .= rawurlencode($schemeHostPath) . '&';
     $data = array();
     parse_str($url->getQuery(), $query);
     $data = array_merge($query, $parameters);
     // normalize data key/values
     array_walk_recursive($data, function (&$key, &$value) {
         $key = rawurlencode(rawurldecode($key));
         $value = rawurlencode(rawurldecode($value));
     });
     ksort($data);
     $baseString .= $this->queryStringFromData($data);
     return $baseString;
 }
开发者ID:dukt,项目名称:craft-oauth,代码行数:27,代码来源:HmacSha1Signature.php

示例5: getSignedUrl

 /**
  * Create a signed Amazon CloudFront URL.
  *
  * Keep in mind that URLs meant for use in media/flash players may have
  * different requirements for URL formats (e.g. some require that the
  * extension be removed, some require the file name to be prefixed
  * - mp4:<path>, some require you to add "/cfx/st" into your URL).
  *
  * @param string              $url     URL to sign (can include query
  *                                     string string and wildcards
  * @param string|integer|null $expires UTC Unix timestamp used when signing
  *                                     with a canned policy. Not required
  *                                     when passing a custom $policy.
  * @param string              $policy  JSON policy. Use this option when
  *                                     creating a signed URL for a custom
  *                                     policy.
  *
  * @return string The file URL with authentication parameters
  * @throws \InvalidArgumentException if the URL provided is invalid
  * @link http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/WorkingWithStreamingDistributions.html
  */
 public function getSignedUrl($url, $expires = null, $policy = null)
 {
     // Determine the scheme of the url
     $urlSections = explode('://', $url);
     if (count($urlSections) < 2) {
         throw new \InvalidArgumentException("Invalid URL: {$url}");
     }
     // Get the real scheme by removing wildcards from the scheme
     $scheme = str_replace('*', '', $urlSections[0]);
     if ($policy) {
         $isCustom = true;
     } else {
         $isCustom = false;
         $policy = $this->createCannedPolicy($scheme, $url, $expires);
     }
     $policy = str_replace(' ', '', $policy);
     $uri = new Uri($scheme . '://' . $urlSections[1]);
     parse_str($uri->getQuery(), $query);
     $query = $this->prepareQuery($isCustom, $policy, $query, $expires);
     $uri = $uri->withQuery(http_build_query($query, null, '&', PHP_QUERY_RFC3986));
     return $scheme === 'rtmp' ? $this->createRtmpUrl($uri) : (string) $uri;
 }
开发者ID:Cinemacloud,项目名称:angular-moviemasher,代码行数:43,代码来源:UrlSigner.php

示例6: getFilters

 protected function getFilters(Request $request)
 {
     $filters = [];
     $facetConfigs = $this->config->get('sunrise.products.facets');
     $uri = new Uri($request->getRequestUri());
     $queryParams = \GuzzleHttp\Psr7\parse_query($uri->getQuery());
     $category = $this->getCategory($request);
     if ($category instanceof Category) {
         $filters['filter'][] = Filter::of()->setName('categories.id')->setValue($category->getId());
     }
     foreach ($queryParams as $filterName => $params) {
         if (!isset($facetConfigs[$filterName])) {
             continue;
         }
         $facetConfig = $facetConfigs[$filterName];
         if ($facetConfig['multi']) {
             if (!is_array($params)) {
                 $params = [$params];
             }
             $filter = Filter::ofType('array');
         } else {
             $filter = Filter::of();
         }
         switch ($facetConfig['type']) {
             case 'text':
                 $filter = $filter->setName('variants.attributes.' . $facetConfig['attribute'])->setValue($params);
                 $filters['filter'][] = $filters['filter.facets'][] = $filter;
                 break;
             case 'enum':
                 $filter = $filter->setName('variants.attributes.' . $facetConfig['attribute'] . '.key')->setValue($params);
                 $filters['filter'][] = $filters['filter.facets'][] = $filter;
                 break;
             default:
                 throw new \InvalidArgumentException('Facet type not implemented');
         }
     }
     return $filters;
 }
开发者ID:sphereio,项目名称:commercetools-sunrise-php,代码行数:38,代码来源:CatalogController.php

示例7: retrieveUri

 /**
  * Retrieve /path?query#fragment part of URL
  * @param $url
  * @return string
  */
 public static function retrieveUri($url)
 {
     $uri = new Psr7Uri($url);
     return (string) (new Psr7Uri())->withPath($uri->getPath())->withQuery($uri->getQuery())->withFragment($uri->getFragment());
 }
开发者ID:hitechdk,项目名称:Codeception,代码行数:10,代码来源:Uri.php

示例8: hasQueryValue

 public static function hasQueryValue(Uri $uri, $key)
 {
     $current = $uri->getQuery();
     $key = strtr($key, self::$replaceQuery);
     if (!$current) {
         $result = [];
     } else {
         $result = [];
         foreach (explode('&', $current) as $part) {
             if (explode('=', $part)[0] === $key) {
                 return true;
             }
         }
     }
     return false;
 }
开发者ID:Gabrola,项目名称:blocktrail-sdk-php,代码行数:16,代码来源:RestClient.php

示例9: testDefaultReturnValuesOfGetters

 public function testDefaultReturnValuesOfGetters()
 {
     $uri = new Uri();
     $this->assertSame('', $uri->getScheme());
     $this->assertSame('', $uri->getAuthority());
     $this->assertSame('', $uri->getUserInfo());
     $this->assertSame('', $uri->getHost());
     $this->assertNull($uri->getPort());
     $this->assertSame('', $uri->getPath());
     $this->assertSame('', $uri->getQuery());
     $this->assertSame('', $uri->getFragment());
 }
开发者ID:nystudio107,项目名称:instantanalytics,代码行数:12,代码来源:UriTest.php


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