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


PHP Url::buildUrl方法代码示例

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


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

示例1: fromParts

public function fromParts(
$method,
array $urlParts,
$headers = null,
$body = null,
$protocol = 'HTTP',
$protocolVersion = '1.1'
) {
return $this->create($method, Url::buildUrl($urlParts), $headers, $body)
->setProtocolVersion($protocolVersion);
}
开发者ID:Ryu0621,项目名称:SaNaVi,代码行数:11,代码来源:RequestFactory.php

示例2: 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(Url $url, $method = 'POST', array $parameters = array())
 {
     $baseString = rawurlencode($method) . '&';
     $schemeHostPath = Url::buildUrl(array('scheme' => $url->getScheme(), 'host' => $url->getHost(), 'path' => $url->getPath()));
     $baseString .= rawurlencode($schemeHostPath) . '&';
     $data = array();
     parse_str($url->getQuery(), $query);
     foreach (array_merge($query, $parameters) as $key => $value) {
         $data[rawurlencode($key)] = rawurlencode($value);
     }
     ksort($data);
     array_walk($data, function (&$value, $key) {
         $value = $key . '=' . $value;
     });
     $baseString .= rawurlencode(implode('&', $data));
     return $baseString;
 }
开发者ID:08euccs014,项目名称:TrueAnalytics,代码行数:27,代码来源:HmacSha1Signature.php

示例3: 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(Url $url, $method = 'POST', array $parameters = array())
 {
     $baseString = rawurlencode($method) . '&';
     $schemeHostPath = Url::buildUrl(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:jtsternberg,项目名称:oauth1-client,代码行数:27,代码来源:HmacSha1Signature.php

示例4: build

 public function build()
 {
     // Resolve configuration
     $config = Collection::fromConfig($this->config, array_merge(self::$commonConfigDefaults, $this->configDefaults), $this->configRequirements);
     // Make sure base_url is correctly set
     if (!($baseUrl = $config->get(Options::BASE_URL))) {
         throw new InvalidArgumentException('You must provide the endpoint for the CloudSearch domain.');
     } elseif (strpos($baseUrl, 'http') !== 0) {
         $config->set(Options::BASE_URL, Url::buildUrl(array('scheme' => $config->get(Options::SCHEME), 'host' => $baseUrl)));
     }
     // Determine the region from the endpoint
     $endpoint = Url::factory($config->get(Options::BASE_URL));
     list(, $region) = explode('.', $endpoint->getHost());
     $config[Options::REGION] = $config[Options::SIGNATURE_REGION] = $region;
     // Create dependencies
     $exceptionParser = new JsonQueryExceptionParser();
     $description = ServiceDescription::factory(sprintf($config->get(Options::SERVICE_DESCRIPTION), $config->get(Options::VERSION)));
     $signature = $this->getSignature($description, $config);
     $credentials = $this->getCredentials($config);
     // Resolve backoff strategy
     $backoff = $config->get(Options::BACKOFF);
     if ($backoff === null) {
         $backoff = new BackoffPlugin(new TruncatedBackoffStrategy(3, new ThrottlingErrorChecker($exceptionParser, new CurlBackoffStrategy(null, new HttpBackoffStrategy(array(500, 503, 509), new ExponentialBackoffStrategy())))));
         $config->set(Options::BACKOFF, $backoff);
     }
     if ($backoff) {
         $this->addBackoffLogger($backoff, $config);
     }
     // Create client
     $client = new CloudSearchDomainClient($credentials, $signature, $config);
     $client->setDescription($description);
     // Add exception marshaling so that more descriptive exception are thrown
     $client->addSubscriber(new ExceptionListener(new NamespaceExceptionFactory($exceptionParser, __NAMESPACE__ . '\\Exception', __NAMESPACE__ . '\\Exception\\CloudSearchDomainException')));
     // Add the UserAgentPlugin to append to the User-Agent header of requests
     $client->addSubscriber(new UserAgentListener());
     // Filters used for the cache plugin
     $client->getConfig()->set('params.cache.key_filter', 'header=date,x-amz-date,x-amz-security-token,x-amzn-authorization');
     // Disable parameter validation if needed
     if ($config->get(Options::VALIDATION) === false) {
         $params = $config->get('command.params') ?: array();
         $params['command.disable_validation'] = true;
         $config->set('command.params', $params);
     }
     return $client;
 }
开发者ID:nstanard,项目名称:webpagetest,代码行数:45,代码来源:CloudSearchDomainClientBuilder.php

示例5: testAddsQueryStringIfPresent

 public function testAddsQueryStringIfPresent()
 {
     $this->assertEquals('?foo=bar', Url::buildUrl(array('query' => 'foo=bar')));
 }
开发者ID:mickdane,项目名称:zidisha,代码行数:4,代码来源:UrlTest.php

示例6: testBuildsUrlsFromParts

 /**
  * @dataProvider urlProvider
  */
 public function testBuildsUrlsFromParts($url, $parts)
 {
     $this->assertEquals($url, Url::buildUrl($parts));
 }
开发者ID:Frinstio,项目名称:AlfredWorkflow.com,代码行数:7,代码来源:UrlParserTest.php

示例7: createMessages

 /**
  * Post multiple messages.
  *
  * @param array $messages
  * @return bool
  */
 public function createMessages(array $messages)
 {
     $objects = array();
     foreach ($messages as $dataArray) {
         $objects[] = $this->getMessage($dataArray)->createJson();
     }
     $json = json_encode(array_slice($objects, 0, self::MAX_POST_MESSAGES));
     $this->checkJsonError();
     $response = $this->getClient()->post($this->getUrl('messages'), self::getJsonHeader(), $json)->send();
     if (null !== ($location = $response->getHeader('Location'))) {
         $parts = array_merge($this->getUrl()->getParts(), parse_url($location));
         $url = Url::factory(Url::buildUrl($parts));
         $options = $this->makeResourceIteratorOptions(__NAMESPACE__ . '\\Message') + array('baseUrl' => $url, 'limit.page' => 10);
         return PaginatedIterator::factory($this, $options);
     }
     return true;
 }
开发者ID:enoch85,项目名称:owncloud-testserver,代码行数:23,代码来源:Queue.php

示例8: getSoapClient

 /**
  * @param string $wsdlUrl
  *
  * @param array $options
  * @return \SoapClient
  */
 protected function getSoapClient($wsdlUrl, array $options = [])
 {
     $options['trace'] = true;
     $urlParts = parse_url($wsdlUrl);
     if (isset($urlParts['user'], $urlParts['pass'])) {
         $options['login'] = $urlParts['user'];
         $options['password'] = $urlParts['pass'];
         unset($urlParts['user'], $urlParts['pass']);
     }
     $wsdlUrl = Url::buildUrl($urlParts);
     return new \SoapClient($wsdlUrl, $options);
 }
开发者ID:Maksold,项目名称:platform,代码行数:18,代码来源:SOAPTransport.php

示例9: createMessages

 /**
  * Post multiple messages.
  *
  * @param array $messages
  * @return bool
  */
 public function createMessages(array $messages)
 {
     $objects = array();
     foreach ($messages as $dataArray) {
         $objects[] = $this->getMessage($dataArray)->createJson();
     }
     $json = json_encode(array_slice($objects, 0, self::MAX_POST_MESSAGES));
     $this->checkJsonError();
     $response = $this->getClient()->post($this->getUrl('messages'), array(), $json)->send();
     if (null !== ($location = $response->getHeader('Location'))) {
         $parts = array_merge($this->getUrl()->getParts(), parse_url($location));
         $url = Url::buildUrl($parts);
         return $this->getService()->resourceList('Message', $url, $this);
     }
     return true;
 }
开发者ID:huhugon,项目名称:sso,代码行数:22,代码来源:Queue.php

示例10: create

 /**
  * Creates a new object
  *
  * @param array $params array of values to set when creating the object
  * @return HttpResponse
  * @throws VolumeCreateError if HTTP status is not Success
  */
 public function create($params = array())
 {
     // set parameters
     if (!empty($params)) {
         $this->populate($params, false);
     }
     // construct the JSON
     $json = json_encode($this->createJson());
     $this->checkJsonError();
     $createUrl = $this->createUrl();
     $response = $this->getClient()->post($createUrl, array(), $json)->setExceptionHandler(array(201 => array('allow' => true, 'callback' => function ($response) use($createUrl) {
         if ($location = $response->getHeader('Location')) {
             $parts = array_merge($createUrl->getParts(), parse_url($location));
             var_dump(Url::buildUrl($parts));
             die;
             $this->refresh(null, Url::buildUrl($parts));
         }
     }), 204 => array('message' => sprintf('Error creating [%s] [%s]', get_class($this), $this->getProperty($this->primaryKeyField())))))->send();
     // We have to try to parse the response body first because it should have precedence over a Location refresh.
     // I'd like to reverse the order, but Nova instances return ephemeral properties on creation which are not
     // available when you follow the Location link...
     if (null !== ($decoded = $this->parseResponse($response))) {
         $this->populate($decoded);
     } elseif ($location = $response->getHeader('Location')) {
         $this->refreshFromLocationUrl($location);
     }
     return $response;
 }
开发者ID:congtrieu112,项目名称:anime,代码行数:35,代码来源:PersistentObject.php

示例11: testHandlesPathsCorrectly

 /**
  * @covers Guzzle\Http\Url::setPath
  * @covers Guzzle\Http\Url::getPath
  * @covers Guzzle\Http\Url::getPathSegments
  * @covers Guzzle\Http\Url::buildUrl
  */
 public function testHandlesPathsCorrectly()
 {
     $url = Url::factory('http://www.test.com');
     $this->assertEquals('/', $url->getPath());
     $url->setPath('test');
     $this->assertEquals('/test', $url->getPath());
     $url->setPath('/test/123/abc');
     $this->assertEquals(array('test', '123', 'abc'), $url->getPathSegments());
     $parts = parse_url('http://www.test.com/test');
     $parts['path'] = '';
     $this->assertEquals('http://www.test.com/', Url::buildUrl($parts));
     $parts['path'] = 'test';
     $this->assertEquals('http://www.test.com/test', Url::buildUrl($parts));
 }
开发者ID:MicroSDHC,项目名称:justinribeiro.com-examples,代码行数:20,代码来源:UrlTest.php


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