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


PHP Http\Url类代码示例

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


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

示例1: buildRequestUrl

 /**
  * @param Actions\ActionsInterface $action
  * @param array                    $requestParams
  * @return Url
  */
 protected function buildRequestUrl(Actions\ActionsInterface $action, array $requestParams)
 {
     $url = new Url('https', $this->connection->getEndpoint());
     $url->setPath($action->getAction());
     $url->setQuery($requestParams);
     return $url;
 }
开发者ID:jdecoster,项目名称:SlackBundle,代码行数:12,代码来源:Client.php

示例2: validateUrl

 private function validateUrl(Url $url)
 {
     // The host must 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 CertificateFromUnrecognizedSourceException();
     }
 }
开发者ID:risyasin,项目名称:webpagetest,代码行数:8,代码来源:MessageValidator.php

示例3: parseServiceName

 /**
  * Parse the AWS service name from a URL
  *
  * @param Url $url HTTP URL
  *
  * @return string Returns a service name (or empty string)
  * @link http://docs.amazonwebservices.com/general/latest/gr/rande.html
  */
 public static function parseServiceName(Url $url)
 {
     // The service name is the first part of the host
     $parts = explode('.', $url->getHost(), 2);
     // Special handling for S3
     if (stripos($parts[0], 's3') === 0) {
         return 's3';
     }
     return $parts[0];
 }
开发者ID:romainneutron,项目名称:aws-sdk-php,代码行数:18,代码来源:HostNameUtils.php

示例4: getLoginUrl

 /**
  * Запрос На авторизацию
  *
  * @param string $redirectUrl Урл для
  * @param string $state       дополнительный get параметр который подставляется к урл
  *
  * @return string
  */
 public function getLoginUrl($redirectUrl, $state = ' ')
 {
     $this->redirectUrl = $redirectUrl;
     $query = new QueryString();
     $query->add('response_type', 'code');
     $query->add('client_id', $this->clientId);
     $query->add('redirect_uri', $redirectUrl);
     $query->add('state', $state);
     //$url = new Url('https','o2.mail.ru',null,null,null,'login',$query);
     $url = new Url('https', 'oauth.yandex.ru', null, null, null, 'authorize', $query);
     return $url->__toString();
 }
开发者ID:cnam,项目名称:yandex_metrica,代码行数:20,代码来源:OAuth.php

示例5: getDescriptionUrl

 /**
  * Get description URL
  *
  * @return Url
  */
 public function getDescriptionUrl()
 {
     if (is_null($this->descriptionUrl)) {
         return Url::factory(SsdpInterface::DEFAULT_DESCRIPTION_URL);
     }
     return $this->descriptionUrl;
 }
开发者ID:T-REX-XP,项目名称:SSDPFinder,代码行数:12,代码来源:AbstractMessage.php

示例6: testParseCookie

 /**
  * @dataProvider cookieParserDataProvider
  */
 public function testParseCookie($cookie, $parsed, $url = null)
 {
     $c = $this->cookieParserClass;
     $parser = new $c();
     $request = null;
     if ($url) {
         $url = Url::factory($url);
         $host = $url->getHost();
         $path = $url->getPath();
     } else {
         $host = '';
         $path = '';
     }
     foreach ((array) $cookie as $c) {
         $p = $parser->parseCookie($c, $host, $path);
         // Remove expires values from the assertion if they are relatively equal by allowing a 5 minute difference
         if ($p['expires'] != $parsed['expires']) {
             if (abs($p['expires'] - $parsed['expires']) < 300) {
                 unset($p['expires']);
                 unset($parsed['expires']);
             }
         }
         if (is_array($parsed)) {
             foreach ($parsed as $key => $value) {
                 $this->assertEquals($parsed[$key], $p[$key], 'Comparing ' . $key . ' ' . var_export($value, true) . ' : ' . var_export($parsed, true) . ' | ' . var_export($p, true));
             }
             foreach ($p as $key => $value) {
                 $this->assertEquals($p[$key], $parsed[$key], 'Comparing ' . $key . ' ' . var_export($value, true) . ' : ' . var_export($parsed, true) . ' | ' . var_export($p, true));
             }
         } else {
             $this->assertEquals($parsed, $p);
         }
     }
 }
开发者ID:bryon-czoch,项目名称:eBay-CLI,代码行数:37,代码来源:CookieParserProvider.php

示例7: fromString

 /**
  * Create response from string
  *
  * @param string $string
  *
  * @return $this
  */
 public static function fromString($string)
 {
     /** @var Discover $message */
     $message = new static();
     foreach (explode(PHP_EOL, trim($string)) as $line) {
         $tuple = explode(':', trim($line), 2);
         if (2 == count($tuple)) {
             $value = trim(array_pop($tuple));
             switch (strtoupper(array_pop($tuple))) {
                 case 'CACHE-CONTROL':
                     $message->setLifetime(intval(substr($value, strpos($value, '=') + 1)));
                     break;
                 case 'DATE':
                     $message->setDate(new DateTime($value));
                     break;
                 case 'LOCATION':
                     $message->setDescriptionUrl(Url::factory($value));
                     break;
                 case 'SERVER':
                     $message->setServerString($value);
                     break;
                 case 'ST':
                     $message->setSearchTarget(SearchTarget::fromString($value));
                     break;
                 case 'USN':
                     $message->setUniqueServiceName(UniqueServiceName::fromString($value));
                     break;
             }
         }
     }
     return $message;
 }
开发者ID:T-REX-XP,项目名称:SSDPFinder,代码行数:39,代码来源:Discover.php

示例8: testCreatesPresignedUrlsWithStrtotime

 public function testCreatesPresignedUrlsWithStrtotime()
 {
     /** @var $client S3Client */
     $client = $this->getServiceBuilder()->get('s3');
     $url = Url::factory($client->createPresignedUrl($client->get('/foobar'), '10 minutes'));
     $this->assertTrue(time() < $url->getQuery()->get('Expires'));
 }
开发者ID:cstuder,项目名称:nagios-plugins,代码行数:7,代码来源:S3ClientTest.php

示例9: getUrl

 /**
  * Returns the URL of the metadata (key or block)
  *
  * @return string
  * @param string $subresource not used; required for strict compatibility
  * @throws ServerUrlerror
  */
 public function getUrl($path = null, array $query = array())
 {
     if (!isset($this->url)) {
         throw new Exceptions\ServerUrlError('Metadata has no URL (new object)');
     }
     return Url::factory($this->url)->addPath($this->key);
 }
开发者ID:huhugon,项目名称:sso,代码行数:14,代码来源:ServerMetadata.php

示例10: testEstimatingTemplateCostMarshalsDataCorrectly

 public function testEstimatingTemplateCostMarshalsDataCorrectly()
 {
     self::log('Estimate a template\'s cost.');
     $result = $this->client->estimateTemplateCost(array('TemplateBody' => file_get_contents(__DIR__ . '/template.json'), 'Parameters' => array(array('ParameterKey' => 'KeyName', 'ParameterValue' => 'keypair-name'))));
     $url = Url::factory($result->get('Url'));
     $this->assertEquals('calculator.s3.amazonaws.com', $url->getHost());
 }
开发者ID:cstuder,项目名称:nagios-plugins,代码行数:7,代码来源:IntegrationTest.php

示例11: onOpen

 /**
  * {@inheritdoc}
  * @throws \UnexpectedValueException If a controller is not \Ratchet\Http\HttpServerInterface
  */
 public function onOpen(ConnectionInterface $conn, RequestInterface $request = null)
 {
     if (null === $request) {
         throw new \UnexpectedValueException('$request can not be null');
     }
     $context = $this->_matcher->getContext();
     $context->setMethod($request->getMethod());
     $context->setHost($request->getHost());
     try {
         $route = $this->_matcher->match($request->getPath());
     } catch (MethodNotAllowedException $nae) {
         return $this->close($conn, 403);
     } catch (ResourceNotFoundException $nfe) {
         return $this->close($conn, 404);
     }
     if (is_string($route['_controller']) && class_exists($route['_controller'])) {
         $route['_controller'] = new $route['_controller']();
     }
     if (!$route['_controller'] instanceof HttpServerInterface) {
         throw new \UnexpectedValueException('All routes must implement Ratchet\\Http\\HttpServerInterface');
     }
     $parameters = array();
     foreach ($route as $key => $value) {
         if (is_string($key) && '_' !== substr($key, 0, 1)) {
             $parameters[$key] = $value;
         }
     }
     $url = Url::factory($request->getPath());
     $url->setQuery($parameters);
     $request->setUrl($url);
     $conn->controller = $route['_controller'];
     $conn->controller->onOpen($conn, $request);
 }
开发者ID:igez,项目名称:gaiaehr,代码行数:37,代码来源:Router.php

示例12: createRedirectRequest

 protected function createRedirectRequest(RequestInterface $request, $statusCode, $location, RequestInterface $original)
 {
     $redirectRequest = null;
     $strict = $original->getParams()->get(self::STRICT_REDIRECTS);
     if ($request instanceof EntityEnclosingRequestInterface && ($statusCode == 303 || !$strict && $statusCode <= 302)) {
         $redirectRequest = RequestFactory::getInstance()->cloneRequestWithMethod($request, 'GET');
     } else {
         $redirectRequest = clone $request;
     }
     $redirectRequest->setIsRedirect(true);
     $redirectRequest->setResponseBody($request->getResponseBody());
     $location = Url::factory($location);
     if (!$location->isAbsolute()) {
         $originalUrl = $redirectRequest->getUrl(true);
         $originalUrl->getQuery()->clear();
         $location = $originalUrl->combine((string) $location, true);
     }
     $redirectRequest->setUrl($location);
     $redirectRequest->getEventDispatcher()->addListener('request.before_send', $func = function ($e) use(&$func, $request, $redirectRequest) {
         $redirectRequest->getEventDispatcher()->removeListener('request.before_send', $func);
         $e['request']->getParams()->set(RedirectPlugin::PARENT_REQUEST, $request);
     });
     if ($redirectRequest instanceof EntityEnclosingRequestInterface && $redirectRequest->getBody()) {
         $body = $redirectRequest->getBody();
         if ($body->ftell() && !$body->rewind()) {
             throw new CouldNotRewindStreamException('Unable to rewind the non-seekable entity body of the request after redirecting. cURL probably ' . 'sent part of body before the redirect occurred. Try adding acustom rewind function using on the ' . 'entity body of the request using setRewindFunction().');
         }
     }
     return $redirectRequest;
 }
开发者ID:Ryu0621,项目名称:SaNaVi,代码行数:30,代码来源:RedirectPlugin.php

示例13: testCreatesPutRequests

 public function testCreatesPutRequests()
 {
     // Test using a string
     $request = RequestFactory::getInstance()->create('PUT', 'http://www.google.com/path?q=1&v=2', null, 'Data');
     $this->assertInstanceOf('Guzzle\\Http\\Message\\EntityEnclosingRequest', $request);
     $this->assertEquals('PUT', $request->getMethod());
     $this->assertEquals('http', $request->getScheme());
     $this->assertEquals('http://www.google.com/path?q=1&v=2', $request->getUrl());
     $this->assertEquals('www.google.com', $request->getHost());
     $this->assertEquals('/path', $request->getPath());
     $this->assertEquals('/path?q=1&v=2', $request->getResource());
     $this->assertInstanceOf('Guzzle\\Http\\EntityBody', $request->getBody());
     $this->assertEquals('Data', (string) $request->getBody());
     unset($request);
     // Test using an EntityBody
     $request = RequestFactory::getInstance()->create('PUT', 'http://www.google.com/path?q=1&v=2', null, EntityBody::factory('Data'));
     $this->assertInstanceOf('Guzzle\\Http\\Message\\EntityEnclosingRequest', $request);
     $this->assertEquals('Data', (string) $request->getBody());
     // Test using a resource
     $resource = fopen('php://temp', 'w+');
     fwrite($resource, 'Data');
     $request = RequestFactory::getInstance()->create('PUT', 'http://www.google.com/path?q=1&v=2', null, $resource);
     $this->assertInstanceOf('Guzzle\\Http\\Message\\EntityEnclosingRequest', $request);
     $this->assertEquals('Data', (string) $request->getBody());
     // Test using an object that can be cast as a string
     $request = RequestFactory::getInstance()->create('PUT', 'http://www.google.com/path?q=1&v=2', null, Url::factory('http://www.example.com/'));
     $this->assertInstanceOf('Guzzle\\Http\\Message\\EntityEnclosingRequest', $request);
     $this->assertEquals('http://www.example.com/', (string) $request->getBody());
 }
开发者ID:mickdane,项目名称:zidisha,代码行数:29,代码来源:RequestFactoryTest.php

示例14: onOpen

 /**
  * {@inheritdoc}
  */
 public function onOpen(ConnectionInterface $conn, RequestInterface $request = null)
 {
     if (null === $request) {
         throw new \UnexpectedValueException('$request can not be null');
     }
     $context = $this->_matcher->getContext();
     $context->setMethod($request->getMethod());
     $context->setHost($request->getHost());
     try {
         $parameters = $this->_matcher->match($request->getPath());
     } catch (MethodNotAllowedException $nae) {
         return $this->close($conn, 403);
     } catch (ResourceNotFoundException $nfe) {
         return $this->close($conn, 404);
     }
     if ($parameters['_controller'] instanceof ServingCapableInterface) {
         $parameters['_controller']->serve($conn, $request, $parameters);
     } else {
         $query = array();
         foreach ($query as $key => $value) {
             if (is_string($key) && '_' !== substr($key, 0, 1)) {
                 $query[$key] = $value;
             }
         }
         $url = Url::factory($request->getPath());
         $url->setQuery($query);
         $request->setUrl($url);
         $conn->controller = $parameters['_controller'];
         $conn->controller->onOpen($conn, $request);
     }
 }
开发者ID:owlycode,项目名称:reactboard,代码行数:34,代码来源:RachetRouter.php

示例15: __construct

 /**
  * @param string $baseUrl
  * @param ConsumerCredentials $consumer
  * @param TokenCredentials $tokenCredentials
  */
 public function __construct($baseUrl, ConsumerCredentials $consumerCredentials, TokenCredentials $tokenCredentials = null)
 {
     // @todo check type of $baseUrl
     $this->baseUrl = Url::factory($baseUrl);
     $this->consumerCredentials = $consumerCredentials;
     $this->tokenCredentials = $tokenCredentials;
 }
开发者ID:cultuurnet,项目名称:auth,代码行数:12,代码来源:OAuthProtectedService.php


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