當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。