• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP GuzzleHttp\Url类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中GuzzleHttp\Url的典型用法代码示例。如果您正苦于以下问题:PHP Url类的具体用法?PHP Url怎么用?PHP Url使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: parseVirtualHosted

 private function parseVirtualHosted(Url $url, array $matches)
 {
     $result = self::$defaultResult;
     $result['path_style'] = false;
     // Remove trailing "." from the prefix to get the bucket
     $result['bucket'] = substr($matches[1], 0, -1);
     $path = $url->getPath();
     // Check if a key was present, and if so, removing the leading "/"
     $result['key'] = !$path || $path == '/' ? null : substr($path, 1);
     return $result;
 }
开发者ID:briareos,项目名称:aws-sdk-php,代码行数:11,代码来源:S3UriParser.php


示例2: getNextRequest

 /**
  * {@inheritdoc}
  */
 public function getNextRequest(ClientInterface $client, JobConfig $jobConfig, $response, $data)
 {
     $nextUrl = Utils::getDataFromPath($this->urlParam, $response, '.');
     if (empty($nextUrl)) {
         return false;
     }
     // start_time validation
     // https://developer.zendesk.com/rest_api/docs/core/incremental_export#incremental-ticket-export
     $now = new \DateTime();
     $startDateTime = \DateTime::createFromFormat('U', Url::fromString($nextUrl)->getQuery()->get('start_time'));
     if ($startDateTime && $startDateTime > $now->modify(sprintf("-%d minutes", self::NEXT_PAGE_FILTER_MINUTES))) {
         return false;
     }
     $config = $jobConfig->getConfig();
     if (!$this->includeParams) {
         $config['params'] = [];
     }
     if (!$this->paramIsQuery) {
         $config['endpoint'] = $nextUrl;
     } else {
         // Create an array from the query string
         $responseQuery = Query::fromString(ltrim($nextUrl, '?'))->toArray();
         $config['params'] = array_replace($config['params'], $responseQuery);
     }
     return $client->createRequest($config);
 }
开发者ID:keboola,项目名称:juicer,代码行数:29,代码来源:ZendeskResponseUrlScroller.php


示例3: __construct

 /**
  * @param AccessTokenInterface $token
  * @param array $options
  */
 public function __construct(AccessTokenInterface $token, array $options = [])
 {
     $options = array_merge($options, ['emitter' => EventsManager::getEmitter()]);
     parent::__construct($options);
     if ($token instanceof OAuth2AccessTokenInterface) {
         $this->getEmitter()->on('before', function (BeforeEvent $event) use($token) {
             /** @var \Eva\EvaOAuth\OAuth2\Token\AccessToken $token */
             $event->getRequest()->setHeader('Authorization', $token->getTokenType() . ' ' . $token->getTokenValue());
         });
     } else {
         $signatureMethod = isset($options['signature_method']) ? $options['signature_method'] : SignatureInterface::METHOD_HMAC_SHA1;
         $signatureClasses = [SignatureInterface::METHOD_PLAINTEXT => 'Eva\\EvaOAuth\\OAuth1\\Signature\\PlainText', SignatureInterface::METHOD_HMAC_SHA1 => 'Eva\\EvaOAuth\\OAuth1\\Signature\\Hmac', SignatureInterface::METHOD_RSA_SHA1 => 'Eva\\EvaOAuth\\OAuth1\\Signature\\Rsa'];
         if (false === isset($signatureClasses[$signatureMethod])) {
             throw new InvalidArgumentException(sprintf('Signature method %s not able to process', $signatureMethod));
         }
         $signatureClass = $signatureClasses[$signatureMethod];
         $this->getEmitter()->on('before', function (BeforeEvent $event) use($token, $signatureClass) {
             /** @var Request $request */
             $request = $event->getRequest();
             /** @var \Eva\EvaOAuth\OAuth1\Token\AccessToken $token */
             $httpMethod = strtoupper($request->getMethod());
             $url = Url::fromString($request->getUrl());
             $parameters = ['oauth_consumer_key' => $token->getConsumerKey(), 'oauth_signature_method' => SignatureInterface::METHOD_HMAC_SHA1, 'oauth_timestamp' => (string) time(), 'oauth_nonce' => strtolower(Text::generateRandomString(32)), 'oauth_token' => $token->getTokenValue(), 'oauth_version' => '1.0'];
             $signature = (string) new $signatureClass($token->getConsumerSecret(), Text::buildBaseString($httpMethod, $url, $parameters), $token->getTokenSecret());
             $parameters['oauth_signature'] = $signature;
             $event->getRequest()->setHeader('Authorization', Text::buildHeaderString($parameters));
         });
     }
 }
开发者ID:assad2012,项目名称:EvaOAuth,代码行数:33,代码来源:AuthorizedHttpClient.php


示例4: buildEndpoint

 /**
  * Builds the URI template for a REST based request.
  *
  * @param array $operation
  * @param array $args
  *
  * @return array
  */
 private function buildEndpoint($operation, array $args)
 {
     $endpoint = Url::fromString($this->endpoint);
     $varspecs = [];
     if (isset($operation['http']['requestUri'])) {
         $endpoint->combine($operation['http']['requestUri']);
         // Create an associative array of varspecs used in expansions
         if (isset($operation['parameters'])) {
             foreach ($operation['parameters'] as $name => $member) {
                 if ($member['location'] == 'uri') {
                     $varspecs[isset($member['locationName']) ? $member['locationName'] : $name] = isset($args[$name]) ? $args[$name] : null;
                 } elseif ($member['location'] == 'query' && !empty($args[$name])) {
                     $endpoint->getQuery()->set($name, $args[$name]);
                 }
             }
         }
     }
     $uri = (string) $endpoint;
     return preg_replace_callback('/%7B([^\\}]+)%7D/', function (array $matches) use($varspecs) {
         $isGreedy = substr($matches[1], -1, 1) == '+';
         $k = $isGreedy ? substr($matches[1], 0, -1) : $matches[1];
         if (!isset($varspecs[$k])) {
             return '';
         } elseif ($isGreedy) {
             return str_replace('%2F', '/', rawurlencode($varspecs[$k]));
         } else {
             return rawurlencode($varspecs[$k]);
         }
     }, $uri);
 }
开发者ID:danielcosta,项目名称:sellercenter-sdk,代码行数:38,代码来源:RestSerializer.php


示例5: getNextRequest

 /**
  * {@inheritdoc}
  */
 public function getNextRequest(ClientInterface $client, JobConfig $jobConfig, $response, $data)
 {
     $nextUrl = Utils::getDataFromPath($this->urlParam, $response, '.');
     if (empty($nextUrl)) {
         return false;
     }
     // since validation - cannot be greater than now
     $now = new \DateTime();
     $sinceDateTime = \DateTime::createFromFormat('U', Url::fromString($nextUrl)->getQuery()->get('since'));
     if ($sinceDateTime && $sinceDateTime > $now) {
         return false;
     }
     $config = $jobConfig->getConfig();
     if (!$this->includeParams) {
         $config['params'] = [];
     }
     if (!$this->paramIsQuery) {
         $config['endpoint'] = $nextUrl;
     } else {
         // Create an array from the query string
         $responseQuery = Query::fromString(ltrim($nextUrl, '?'))->toArray();
         $config['params'] = array_replace($config['params'], $responseQuery);
     }
     return $client->createRequest($config);
 }
开发者ID:keboola,项目名称:juicer,代码行数:28,代码来源:FacebookResponseUrlScroller.php


示例6: validateUrl

 /**
  * Ensures that the url of the certificate is one belonging to AWS, and not
  * just something from the amazonaws domain, which includes S3 buckets.
  *
  * @param Url $url
  *
  * @throws MessageValidatorException if the cert url is invalid
  */
 private function validateUrl(Url $url)
 {
     // The cert URL must be https, a .pem, and match the following pattern.
     $hostPattern = '/^sns\\.[a-zA-Z0-9\\-]{3,}\\.amazonaws\\.com(\\.cn)?$/';
     if ($url->getScheme() !== 'https' || substr($url, -4) !== '.pem' || !preg_match($hostPattern, $url->getHost())) {
         throw new MessageValidatorException('The certificate is located ' . 'on an invalid domain.');
     }
 }
开发者ID:briareos,项目名称:aws-sdk-php,代码行数:16,代码来源:MessageValidator.php


示例7: onPrepared

 public function onPrepared(PreparedEvent $event)
 {
     $command = $event->getCommand();
     if ($command->hasParam('QueueUrl')) {
         $request = $event->getRequest();
         $url = Url::fromString($request->getUrl());
         $request->setUrl($url->combine($command['QueueUrl']));
     }
 }
开发者ID:briareos,项目名称:aws-sdk-php,代码行数:9,代码来源:QueueUrlSubscriber.php


示例8: testStripsFragmentFromHost

 public function testStripsFragmentFromHost()
 {
     Server::flush();
     Server::enqueue("HTTP/1.1 200 OK\r\n\r\nContent-Length: 0\r\n\r\n");
     // This will fail if the removal of the #fragment is not performed
     $url = Url::fromString(Server::$url)->setPath(null)->setFragment('foo');
     $client = new Client();
     $client->get($url);
 }
开发者ID:hilmysyarif,项目名称:sic,代码行数:9,代码来源:AbstractCurl.php


示例9: getArguments

 public static function getArguments()
 {
     $args = parent::getArguments();
     $args['endpoint']['required'] = true;
     $args['region']['default'] = function (array $args) {
         // Determine the region from the provided endpoint.
         // (e.g. http://search-blah.{region}.cloudsearch.amazonaws.com)
         return explode('.', Url::fromString($args['endpoint']))[1];
     };
     return $args;
 }
开发者ID:briareos,项目名称:aws-sdk-php,代码行数:11,代码来源:CloudSearchDomainClient.php


示例10: serialize

 /**
  * @param array       $userValues  The user-defined values that will populate the JSON
  * @param []Parameter $params      The parameter schemas that define how each value is populated.
  *                                 For example, specifying any deep nesting or aliasing.
  * @param string      $inputString The initial URL string being decorated.
  *
  * @return Url
  */
 public function serialize($userValues, array $params, $inputString)
 {
     $url = Url::fromString($inputString);
     $query = new Query();
     foreach ($userValues as $paramName => $value) {
         $schema = $params[$paramName];
         if (!$schema->hasLocation('query')) {
             continue;
         }
         $query->set($schema->getName(), $value);
     }
     $url->setQuery($query);
     return $url;
 }
开发者ID:boxrice007,项目名称:openstack,代码行数:22,代码来源:QuerySerializer.php


示例11: createPresignedUrl

 private function createPresignedUrl(AwsClientInterface $client, CommandInterface $cmd)
 {
     $newCmd = $client->getCommand('CopySnapshot', $cmd->toArray());
     $newCmd->getEmitter()->detach($this);
     // Serialize a request for the CopySnapshot operation.
     $request = $client->initTransaction($newCmd)->request;
     // Create the new endpoint for the target endpoint.
     $endpoint = EndpointProvider::resolve($this->endpointProvider, ['region' => $cmd['SourceRegion'], 'service' => 'ec2'])['endpoint'];
     // Set the request to hit the target endpoint.
     $request->setHost(Url::fromString($endpoint)->getHost());
     // Create a presigned URL for our generated request.
     $signer = new SignatureV4('ec2', $cmd['SourceRegion']);
     return $signer->createPresignedUrl(SignatureV4::convertPostToGet($request), $client->getCredentials(), '+1 hour');
 }
开发者ID:briareos,项目名称:aws-sdk-php,代码行数:14,代码来源:CopySnapshotSubscriber.php


示例12: fromMessage

 /**
  * Create a request or response object from an HTTP message string
  *
  * @param string $message Message to parse
  *
  * @return RequestInterface|ResponseInterface
  * @throws \InvalidArgumentException if unable to parse a message
  */
 public function fromMessage($message)
 {
     static $parser;
     if (!$parser) {
         $parser = new MessageParser();
     }
     // Parse a response
     if (strtoupper(substr($message, 0, 4)) == 'HTTP') {
         $data = $parser->parseResponse($message);
         return $this->createResponse($data['code'], $data['headers'], $data['body'] === '' ? null : $data['body'], $data);
     }
     // Parse a request
     if (!($data = $parser->parseRequest($message))) {
         throw new \InvalidArgumentException('Unable to parse request');
     }
     return $this->createRequest($data['method'], Url::buildUrl($data['request_url']), ['headers' => $data['headers'], 'body' => $data['body'] === '' ? null : $data['body'], 'config' => ['protocol_version' => $data['protocol_version']]]);
 }
开发者ID:hilmysyarif,项目名称:sic,代码行数:25,代码来源:MessageFactory.php


示例13: __construct

 /**
  * @param array $config  Service description data
  * @param array $options Custom options to apply to the description
  *     - formatter: Can provide a custom SchemaFormatter class
  *
  * @throws \InvalidArgumentException
  */
 public function __construct(array $config, array $options = [])
 {
     // Keep a list of default keys used in service descriptions that is
     // later used to determine extra data keys.
     static $defaultKeys = ['name', 'models', 'apiVersion', 'description'];
     // Pull in the default configuration values
     foreach ($defaultKeys as $key) {
         if (isset($config[$key])) {
             $this->{$key} = $config[$key];
         }
     }
     // Set the baseUrl
     $this->baseUrl = Url::fromString(isset($config['baseUrl']) ? $config['baseUrl'] : '');
     // Ensure that the models and operations properties are always arrays
     $this->models = (array) $this->models;
     $this->operations = (array) $this->operations;
     // We want to add operations differently than adding the other properties
     $defaultKeys[] = 'operations';
     // Create operations for each operation
     if (isset($config['operations'])) {
         foreach ($config['operations'] as $name => $operation) {
             if (!is_array($operation)) {
                 throw new \InvalidArgumentException('Operations must be arrays');
             }
             $this->operations[$name] = $operation;
         }
     }
     // Get all of the additional properties of the service description and
     // store them in a data array
     foreach (array_diff(array_keys($config), $defaultKeys) as $key) {
         $this->extraData[$key] = $config[$key];
     }
     // Configure the schema formatter
     if (isset($options['formatter'])) {
         $this->formatter = $options['formatter'];
     } else {
         static $defaultFormatter;
         if (!$defaultFormatter) {
             $defaultFormatter = new SchemaFormatter();
         }
         $this->formatter = $defaultFormatter;
     }
 }
开发者ID:danieledangeli,项目名称:guzzle-services,代码行数:50,代码来源:Description.php


示例14: buildRequestSet

 /**
  *
  * @param string $url
  * @return HttpRequest[]
  */
 private function buildRequestSet($url)
 {
     $useEncodingOptions = $this->getConfiguration()->getToggleUrlEncoding() ? array(true, false) : array(true);
     $requests = array();
     $userAgentSelection = $this->getConfiguration()->getUserAgentSelectionForRequest();
     foreach ($userAgentSelection as $userAgent) {
         foreach ($this->getConfiguration()->getHttpMethodList() as $methodIndex => $method) {
             foreach ($useEncodingOptions as $useEncoding) {
                 $requestUrl = GuzzleUrl::fromString($url);
                 $requestUrl->getQuery()->setEncodingType($useEncoding ? GuzzleQuery::RFC3986 : false);
                 $request = $this->getConfiguration()->getHttpClient()->createRequest('GET', $requestUrl);
                 $request->setHeader('user-agent', $userAgent);
                 if ($this->getConfiguration()->hasReferrer()) {
                     $request->setHeader('Referer', $this->getConfiguration()->getReferrer());
                 }
                 $requests[] = $request;
             }
         }
     }
     return $requests;
 }
开发者ID:webignition,项目名称:url-health-checker,代码行数:26,代码来源:UrlHealthChecker.php


示例15: extractHeaders

 private function extractHeaders(BrowserKitRequest $request)
 {
     $headers = array();
     $server = $request->getServer();
     $uri = Url::fromString($request->getUri());
     $server['HTTP_HOST'] = $uri->getHost();
     $port = $uri->getPort();
     if ($port !== null && $port !== 443 && $port != 80) {
         $server['HTTP_HOST'] .= ':' . $port;
     }
     $contentHeaders = array('Content-Length' => true, 'Content-Md5' => true, 'Content-Type' => true);
     foreach ($server as $header => $val) {
         $header = implode('-', array_map('ucfirst', explode('-', strtolower(str_replace('_', '-', $header)))));
         if (strpos($header, 'Http-') === 0) {
             $headers[substr($header, 5)] = $val;
         } elseif (isset($contentHeaders[$header])) {
             $headers[$header] = $val;
         }
     }
     $zendHeaders = new HttpHeaders();
     $zendHeaders->addHeaders($headers);
     return $zendHeaders;
 }
开发者ID:kansey,项目名称:yii2albom,代码行数:23,代码来源:ZF2.php


示例16: onPostFetch

 /**
  * Subscribes to a feed.
  */
 public function onPostFetch(FetchEvent $event)
 {
     $feed = $event->getFeed();
     $fetcher = $feed->getType()->getFetcher();
     $subscription = $this->storage->load($feed->id());
     if (!$fetcher->getConfiguration('use_pubsubhubbub')) {
         return $this->unsubscribe($feed, $subscription);
     }
     if (!($hub = $this->findRelation($event->getFetcherResult(), 'hub'))) {
         $hub = $fetcher->getConfiguration('fallback_hub');
     }
     // No hub found.
     if (!$hub) {
         return $this->unsubscribe($feed, $subscription);
     }
     // Used to make other URLs absolute.
     $source_url = Url::fromString($feed->getSource());
     $hub = (string) $source_url->combine($hub);
     // If there is a rel="self" relation.
     if ($topic = $this->findRelation($event->getFetcherResult(), 'self')) {
         $topic = (string) $source_url->combine($topic);
         $feed->setSource($topic);
     } else {
         $topic = $feed->getSource();
     }
     // Subscription does not exist yet.
     if (!$subscription) {
         $subscription = $this->storage->create(['fid' => $feed->id(), 'topic' => $topic, 'hub' => $hub]);
         return $this->subscribe($feed, $subscription);
     }
     if ($topic !== $subscription->getTopic() || $subscription->getHub() !== $hub || $subscription->getState() !== 'subscribed') {
         // Unsubscribe from the old feed.
         $this->unsubscribe($feed, $subscription);
         $subscription = $this->storage->create(['fid' => $feed->id(), 'topic' => $topic, 'hub' => $hub]);
         return $this->subscribe($feed, $subscription);
     }
 }
开发者ID:Tawreh,项目名称:mtg,代码行数:40,代码来源:PubSubHubbub.php


示例17: setUrl

 public function setUrl($url)
 {
     $this->url = $url instanceof Url ? $url : Url::fromString($url);
     $this->updateHostHeaderFromUrl();
     return $this;
 }
开发者ID:sacredwebsite,项目名称:rainloop-webmail,代码行数:6,代码来源:Request.php


示例18: getSsoUrl

 public function getSsoUrl()
 {
     $params = array('response_type' => 'code', 'client_id' => $this->config['ssoClientId'], 'redirect_uri' => $this->config['ssoRedirectUrl'], 'scope' => AuthenticationSubscriber::SSO_SCOPE);
     $url = Url::fromString($this->config['ssoBaseUrl']);
     $url->setPath('/oauth/authorize');
     $url->setQuery($params);
     return (string) $url;
 }
开发者ID:sitra-tourisme,项目名称:sitra-api-php,代码行数:8,代码来源:Client.php


示例19: getAbsoluteUrlFor

 /**
  * Returns an absolute URL for the passed URI with the current URL
  * as the base path.
  *
  * @param string $uri the absolute or relative URI
  * @return string the absolute URL
  * @throws Codeception\Exception\TestRuntime if either the current
  *         URL or the passed URI can't be parsed
  */
 protected function getAbsoluteUrlFor($uri)
 {
     $currentUrl = $this->client->getHistory()->current()->getUri();
     if (empty($uri) || $uri === '#') {
         return $currentUrl;
     }
     $build = parse_url($currentUrl);
     $uriParts = parse_url($uri);
     if ($build === false) {
         throw new TestRuntime("URL '{$currentUrl}' is malformed");
     } elseif ($uriParts === false) {
         throw new TestRuntime("URI '{$uri}' is malformed");
     }
     $abs = $this->mergeUrls($build, $uriParts);
     return \GuzzleHttp\Url::buildUrl($abs);
 }
开发者ID:alexanderkuz,项目名称:test-yii2,代码行数:25,代码来源:InnerBrowser.php


示例20: testCanUseUrlWithCustomQuery

 public function testCanUseUrlWithCustomQuery()
 {
     $client = new Client();
     $url = Url::fromString('http://foo.com/bar');
     $query = new Query(['baz' => '123%20']);
     $query->setEncodingType(false);
     $url->setQuery($query);
     $r = $client->createRequest('GET', $url);
     $this->assertEquals('http://foo.com/bar?baz=123%20', $r->getUrl());
 }
开发者ID:EarthTeam,项目名称:earthteam.net,代码行数:10,代码来源:ClientTest.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Event\BeforeEvent类代码示例发布时间:2022-05-23
下一篇:
PHP GuzzleHttp\Middleware类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap