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


PHP Uri::resolve方法代码示例

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


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

示例1: getForm

 public function getForm($formId, $params, $headers)
 {
     /** @var DOMElement $form */
     $dom = new DomDocument();
     libxml_use_internal_errors(true);
     $dom->loadHTML($this->response());
     $xpath = new DOMXpath($dom);
     $form = $xpath->query("//form[@id='{$formId}']")->item(0);
     $elements = $xpath->query('//input');
     $form_params = [];
     $allowedTypes = ["hidden", "text", "password"];
     foreach ($elements as $element) {
         /** @var DOMElement $element */
         $type = $element->getAttribute("type");
         if (in_array($type, $allowedTypes)) {
             $name = $element->getAttribute("name");
             $value = $element->getAttribute("value");
             $form_params[$name] = $value;
         }
     }
     $headers = array_merge(["Referer" => $this->baseUri], $headers);
     $url = Uri::resolve(new Uri($this->baseUri), $form->getAttribute("action"))->__toString();
     $method = strtoupper($form->getAttribute("method"));
     return ["method" => $method, "url" => $url, "headers" => $headers, "params" => array_merge($form_params, $params)];
 }
开发者ID:ifgroup,项目名称:browser,代码行数:25,代码来源:Browser.php

示例2: convertUrlsToAbsolute

 /**
  * Convert relative links, images scr and form actions to absolute
  *
  * @param ElementFinder $page
  * @param string $affectedUrl
  */
 public static function convertUrlsToAbsolute(ElementFinder $page, $affectedUrl)
 {
     $affected = new Uri($affectedUrl);
     $srcElements = $page->element('//*[@src] | //*[@href] | //form[@action]');
     $baseUrl = $page->value('//base/@href')->getFirst();
     foreach ($srcElements as $element) {
         $attributeName = 'href';
         if ($element->hasAttribute('action') === true and $element->tagName === 'form') {
             $attributeName = 'action';
         } else {
             if ($element->hasAttribute('src') === true) {
                 $attributeName = 'src';
             }
         }
         $relative = $element->getAttribute($attributeName);
         # don`t change javascript in href
         if (preg_match('!^\\s*javascript\\s*:\\s*!', $relative)) {
             continue;
         }
         if (parse_url($relative) === false) {
             continue;
         }
         if (!empty($baseUrl) and !preg_match('!^(/|http)!i', $relative)) {
             $relative = Uri::resolve(new Uri($baseUrl), $relative);
         }
         $url = Uri::resolve($affected, (string) $relative);
         $element->setAttribute($attributeName, (string) $url);
     }
 }
开发者ID:xparse,项目名称:parser,代码行数:35,代码来源:LinkConverter.php

示例3: uriFor

 /**
  * @param string $filename
  * @param string $version
  *
  * @return \Psr\Http\Message\UriInterface
  */
 public function uriFor($filename, $version = '')
 {
     $filename = original_version($filename);
     if ($version) {
         $filename .= ":{$version}";
     }
     return Uri::resolve($this->baseUri, $filename);
 }
开发者ID:livetyping,项目名称:hermitage-php-client,代码行数:14,代码来源:Client.php

示例4: request

 /**
  * @param $httpMethod
  * @param $url
  * @param $blueprint
  * @param array $options
  *
  * @return array
  * @throws \GuzzleHttp\Exception\GuzzleException
  */
 protected function request($httpMethod, $url, $blueprint, $options = [])
 {
     $url = Uri::resolve($this->getBaseUrl(), $url);
     $this->currentMethod = new ApistMethod($this->getGuzzle(), $url, $blueprint);
     $this->lastMethod = $this->currentMethod;
     $this->currentMethod->setMethod($httpMethod);
     $result = $this->currentMethod->get($options);
     $this->currentMethod = null;
     return $result;
 }
开发者ID:noxify,项目名称:apist,代码行数:19,代码来源:Apist.php

示例5: get

 public function get($url, array $options = [], \Closure $processor = null)
 {
     $url = Psr7\Uri::resolve($this->baseUri, $url);
     $response = $this->httpClient->get($url, $options);
     if (null !== $processor) {
         $response = $processor($response);
     }
     $crawler = new Crawler(null, (string) $url, (string) $this->baseUri);
     $crawler->addContent($response->getBody());
     return $crawler;
 }
开发者ID:webuni,项目名称:srazy-api-client,代码行数:11,代码来源:Client.php

示例6: resolveLinkAttribute

 /**
  * @param  string       $attribute
  * @param  UriInterface $base
  */
 private function resolveLinkAttribute($attribute, UriInterface $base)
 {
     $elements = $this->xpath->query("//*[@{$attribute} and not(contains(@{$attribute}, \"://\"))]");
     foreach ($elements as $element) {
         try {
             $resolved = Uri::resolve($base, $element->getAttribute($attribute));
             $element->setAttribute($attribute, $resolved->__toString());
         } catch (InvalidArgumentException $e) {
             // Tolerate invalid urls
         }
     }
 }
开发者ID:spiderling-php,项目名称:spiderling,代码行数:16,代码来源:Html.php

示例7: queueUrl

 /**
  * Moves the URI of the queue to the URI in the input parameter.
  *
  * @return callable
  */
 private function queueUrl()
 {
     return static function (callable $handler) {
         return function (CommandInterface $c, RequestInterface $r = null) use($handler) {
             if ($c->hasParam('QueueUrl')) {
                 $uri = Uri::resolve($r->getUri(), $c['QueueUrl']);
                 $r = $r->withUri($uri);
             }
             return $handler($c, $r);
         };
     };
 }
开发者ID:AWSRandall,项目名称:aws-sdk-php,代码行数:17,代码来源:SqsClient.php

示例8: signRequest

 /**
  * @param RequestInterface $request
  * @param bool             $forceNew
  *
  * @return RequestInterface
  */
 public function signRequest(RequestInterface $request, $forceNew = false)
 {
     try {
         // force-get a new token if it was requested, if not, the regular
         // caching mechanism will be used so the call is not necessary here.
         if (true === $forceNew) {
             $this->pool->getToken($forceNew);
         }
         // create a new request with the new uri and the token added to the headers
         $uri = Uri::resolve(new Uri($this->pool->getEndpointUrl()), $request->getUri());
         return $request->withUri($uri)->withHeader('X-Auth-Token', $this->pool->getTokenId());
     } catch (TokenException $e) {
         throw new ClientException('Could not obtain token', $request, null, $e);
     }
 }
开发者ID:treehouselabs,项目名称:keystone-client,代码行数:21,代码来源:RequestSigner.php

示例9: proxy

 /**
  * @param $endpoint
  * @param ServerRequestInterface $request
  *
  * @return ResponseInterface
  */
 public function proxy($endpoint, ServerRequestInterface $request)
 {
     /** @var ClientInterface $client */
     $client = $this->container->get('bangpound_guzzle_proxy.client.' . $endpoint);
     $rel = $request->getAttribute('path');
     if ($request->getQueryParams()) {
         $rel .= '?' . \GuzzleHttp\Psr7\build_query($request->getQueryParams());
     }
     $rel = new Uri($rel);
     $uri = $client->getConfig('base_url');
     $uri = new Uri($uri);
     $uri = Uri::resolve($uri, $rel);
     $request = \GuzzleHttp\Psr7\modify_request($request, array('uri' => $uri));
     $response = $client->send($request);
     if ($response->hasHeader('Transfer-Encoding')) {
         $response = $response->withoutHeader('Transfer-Encoding');
     }
     return $response;
 }
开发者ID:bangpound,项目名称:guzzle-proxy-bundle,代码行数:25,代码来源:ProxyController.php

示例10: get

 public static function get($path, $query = [])
 {
     if (!isset(self::$guzzle)) {
         self::initUsingConfigFile();
     }
     if (is_array($query)) {
         $query = self::weedOut($query);
         $query = http_build_query($query, null, '&', PHP_QUERY_RFC3986);
         $query = preg_replace('/%5[bB]\\d+%5[dD]=/', '=', $query);
     }
     $response = self::$guzzle->get($path, ['query' => $query]);
     switch ($response->getStatusCode()) {
         case 200:
             return json_decode($response->getBody(), true);
         case 404:
             return null;
         default:
             $uri = Psr7\Uri::resolve(Psr7\uri_for(self::$guzzle->getConfig('base_uri')), $path);
             $uri = $uri->withQuery($query);
             throw new ServerException($response->getStatusCode() . " " . $response->getReasonPhrase() . ". URI: " . $uri);
     }
 }
开发者ID:dsv-su,项目名称:daisy-api-client-php,代码行数:22,代码来源:Client.php

示例11: testResolvesUris

 /**
  * @dataProvider getResolveTestCases
  */
 public function testResolvesUris($base, $rel, $expected)
 {
     $uri = new Uri($base);
     $actual = Uri::resolve($uri, $rel);
     $this->assertEquals($expected, (string) $actual);
 }
开发者ID:shomimn,项目名称:builder,代码行数:9,代码来源:UriTest.php

示例12: buildUri

 private function buildUri($uri, array $config)
 {
     // for BC we accept null which would otherwise fail in uri_for
     $uri = Psr7\uri_for($uri === null ? '' : $uri);
     if (isset($config['base_uri'])) {
         $uri = Psr7\Uri::resolve(Psr7\uri_for($config['base_uri']), $uri);
     }
     return $uri->getScheme() === '' ? $uri->withScheme('http') : $uri;
 }
开发者ID:sgtsaughter,项目名称:d8portfolio,代码行数:9,代码来源:Client.php

示例13: buildUri

 private function buildUri($uri, array $config)
 {
     if (!isset($config['base_uri'])) {
         return $uri instanceof UriInterface ? $uri : new Psr7\Uri($uri);
     }
     return Psr7\Uri::resolve(Psr7\uri_for($config['base_uri']), $uri);
 }
开发者ID:Sebascii,项目名称:guzzle,代码行数:7,代码来源:Client.php

示例14: fixUri

 private function fixUri(Step $step, $uri)
 {
     if (!$step->getEndpoint()) {
         return $uri;
     }
     return Psr7\Uri::resolve(Psr7\uri_for($step->getEndpoint()), $uri);
 }
开发者ID:stof,项目名称:player,代码行数:7,代码来源:RequestFactory.php

示例15: createRequest

 private function createRequest($uri)
 {
     $baseUri = \GuzzleHttp\Psr7\uri_for($this->client->getConfig('base_uri'));
     $uri = Uri::resolve($baseUri, $uri);
     return new Request('GET', $uri);
 }
开发者ID:vierbergenlars,项目名称:authserver-client,代码行数:6,代码来源:AbstractPaginatedResultSet.php


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