當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Url::setQuery方法代碼示例

本文整理匯總了PHP中Nette\Http\Url::setQuery方法的典型用法代碼示例。如果您正苦於以下問題:PHP Url::setQuery方法的具體用法?PHP Url::setQuery怎麽用?PHP Url::setQuery使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Nette\Http\Url的用法示例。


在下文中一共展示了Url::setQuery方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: __construct

 public function __construct(OAuth\Consumer $consumer, Http\Url $url, $method = self::GET, array $post = [], array $headers = [], OAuth\Token $token = NULL)
 {
     $this->consumer = $consumer;
     $this->token = $token;
     $this->url = $url;
     $this->method = strtoupper($method);
     $this->headers = $headers;
     if (is_array($post) && !empty($post)) {
         $this->post = array_map(function ($value) {
             if ($value instanceof Http\UrlScript) {
                 return (string) $value;
             } elseif ($value instanceof \CURLFile) {
                 return $value;
             }
             return !is_string($value) ? Utils\Json::encode($value) : $value;
         }, $post);
     }
     $parameters = $this->getParameters();
     $defaults = ['oauth_version' => OAuth\DI\OAuthExtension::VERSION, 'oauth_nonce' => $this->generateNonce(), 'oauth_timestamp' => $this->generateTimestamp(), 'oauth_consumer_key' => $this->consumer->getKey()];
     if ($token && $token->getToken()) {
         $defaults['oauth_token'] = $this->token->getToken();
     }
     // Update query parameters
     $this->url->setQuery(array_merge($defaults, $parameters));
 }
開發者ID:pkristian,項目名稱:flickrlickr,代碼行數:25,代碼來源:Request.php

示例2: setParam

 public function setParam($key, $value)
 {
     $this->queryArray[$key] = $value;
     parent::setQuery(\http_build_query($this->queryArray));
 }
開發者ID:kathynka,項目名稱:Foundation,代碼行數:5,代碼來源:Url.php

示例3: getUrl

 /**
  * Generates URL to PayPal for redirection.
  *
  * @param bool $commit determines whether buyers complete their purchases on PayPal or on your website
  *
  * @return Nette\Http\Url
  */
 public function getUrl($commit = false)
 {
     $url = new Url($this->sandbox ? self::SANDBOX_PAYPAL_URL : self::PAYPAL_URL);
     $query = array('cmd' => '_express-checkout', 'token' => $this->token);
     if ($commit) {
         $query['useraction'] = 'commit';
     }
     $url->setQuery($query);
     return $url;
 }
開發者ID:MartinKokesCz,項目名稱:nette-paypal,代碼行數:17,代碼來源:API.php

示例4: getUrl

 /**
  * Generates URL to PayPal for redirection.
  * @return Nette\Http\Url
  */
 public function getUrl()
 {
     $url = new Url($this->sandbox ? self::SANDBOX_PAYPAL_URL : self::PAYPAL_URL);
     $query = array('cmd' => '_express-checkout', 'token' => $this->token);
     $url->setQuery($query);
     return $url;
 }
開發者ID:rostenkowski,項目名稱:nette-adons,代碼行數:11,代碼來源:API.class.php

示例5: constructUrl

 /**
  * @param Request $appRequest
  * @param Url $refUrl
  * @return null|string
  */
 public function constructUrl(Request $appRequest, Url $refUrl)
 {
     // one way can't generate link
     if ($this->options['oneWay']) {
         return NULL;
     }
     $params = $this->clearParameters($appRequest->getParameters());
     $action = new Action($appRequest->getPresenterName() . ':' . $appRequest->getParameter('action'), $params);
     // ISource return NULL, not found url to generate
     if (($seoUrl = $this->source->toUrl($action)) === NULL) {
         return NULL;
     }
     if (!$seoUrl instanceof Url) {
         $seoUrl = new Url($seoUrl);
     }
     // host
     if ($seoUrl->getHost()) {
         $host = $refUrl->getHost();
         $parts = ip2long($host) ? [$host] : array_reverse(explode('.', $host));
         $host = strtr($seoUrl->getHost(), ['%tld%' => $parts[0], '%domain%' => isset($parts[1]) ? "{$parts['1']}.{$parts['0']}" : $parts[0], '%sld%' => isset($parts[1]) ? $parts[1] : '', '%host%' => $refUrl->getHost()]);
     } else {
         $host = $refUrl->getHost();
     }
     // path
     $path = $seoUrl->getPath();
     // query
     $query = $seoUrl->getQueryParameters() + $params;
     ksort($query);
     $seoUrl->setQuery($query);
     $query = $seoUrl->getQuery();
     // fragment
     $fragment = $seoUrl->getFragment();
     return ($this->options['secured'] ? 'https' : 'http') . '://' . $host . $refUrl->getBasePath() . ($path === '/' ? '' : $path) . ($query ? '?' . $query : '') . ($fragment ? '#' . $fragment : '');
 }
開發者ID:Myiyk,項目名稱:seo-router,代碼行數:39,代碼來源:Router.php

示例6: send

 /**
  * Send request
  *
  * @param string|null $resource Optional resource
  * @param string|null $action   Optional action
  * @param array|null  $values   Optional values
  * @param string|null $method   Optional method
  *
  * @return array
  */
 public function send($resource = null, $action = null, $values = null, $method = null)
 {
     if ($resource) {
         $this->setResource($resource);
     }
     if ($action) {
         $this->setAction($action);
     }
     if ($method) {
         $this->setMethod($method);
     }
     if ($values) {
         $this->setValues($values);
     }
     if ($this->method === self::POST || $this->method === self::PUT) {
         $content = $this->values;
         $url = new Url();
         $url->setPath($this->getResource());
         $url->setQuery(['action' => $this->getAction()]);
     } else {
         $content = [];
         $url = new Url();
         $url->setPath($this->getResource());
         $url->setQuery(array_merge(['action' => $this->getAction()], $this->getValues()));
     }
     $result = $this->adapter->query($url->getPath() . '?' . $url->getQuery(), $this->method, $content);
     if ($result->success === false) {
         throw new Exception\AdapterException(json_encode($result->messages), (string) $url);
     }
     if (!isset($result->body)) {
         throw new Exception\AdapterException('Body not provided in response!', (string) $url);
     }
     return ArrayUtils::objectToArray($result->body);
 }
開發者ID:bauer01,項目名稱:unimapper-nette,代碼行數:44,代碼來源:CustomRequest.php


注:本文中的Nette\Http\Url::setQuery方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。