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


PHP Uri::setQuery方法代码示例

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


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

示例1: __construct

 /**
  * Constructor
  *
  * @param OAuth\Consumer $consumer
  * @param string $url
  * @param string $method
  * @param array $params
  */
 public function __construct($consumer, $url, $method, $params = array())
 {
     $this->_consumer = $consumer;
     $this->_method = $method;
     //normalize the uri: remove the query params
     //and store them alonside the oauth and user params
     $this->_uri = new \MediaCore\Uri($url);
     $this->_unencodedQueryParams = $this->_uri->getQueryAsArray(true);
     $this->_uri->setQuery('');
     $this->_params = $params;
 }
开发者ID:mediacore,项目名称:mediacore-client-php,代码行数:19,代码来源:Request.php

示例2: constructRedirectUri

 protected function constructRedirectUri($uri = null, array $query = array())
 {
     $uri = new Uri($uri);
     if (!empty($query)) {
         $query = $uri->getQueryAsArray() + $query;
         $uri->setQuery($query);
     }
     return $uri;
 }
开发者ID:ivan-novakov,项目名称:zf2-openid-connect-server-module,代码行数:9,代码来源:AbstractAuthorizeResponse.php

示例3: request

 /**
  * @param                    $method
  * @param                    $uri
  * @param array              $options
  * @param null|bool|\Closure $successCallback
  * @param null|bool|\Closure $failCallback
  *
  * @return bool|null|\StdClass
  * @throws Exception
  */
 public function request($method, $uri, $options = [], $successCallback = null, $failCallback = null)
 {
     if (!$successCallback && !$failCallback) {
         $json = null;
         // If there's no callbacks defined we assume this is a RESTful request
         Logger::getInstance()->debug($method . ' ' . $uri . ' ' . json_encode($options));
         $options = array_merge($this->defaultOptions, $options);
         $guzzle = new GuzzleHttp\Client(['base_uri' => self::BASE_URL_REST]);
         $res = $guzzle->request($method, $uri, $options);
         if ($res->getHeader('content-type')[0] == 'application/json') {
             $contents = $res->getBody()->getContents();
             Logger::getInstance()->debug($contents);
             $json = json_decode($contents);
         } else {
             throw new Exception("Server did not send JSON. Response was \"{$res->getBody()->getContents()}\"");
         }
         return $json;
     } else {
         // Use the STREAM API end point
         $Uri = new Uri(self::BASE_URL_STREAM);
         $Uri->setUserInfo($this->defaultOptions['auth'][0] . ':' . $this->defaultOptions['auth'][1]);
         $Uri->setPath($uri);
         if (isset($options['query'])) {
             $Uri->setQuery($options['query']);
         }
         $WSClient = new WebSocket\Client($Uri);
         Logger::getInstance()->debug($Uri);
         if (!$successCallback instanceof \Closure) {
             $successCallback = function ($response) {
                 $info = json_decode($response);
                 if (property_exists($info, 'output')) {
                     Logger::getInstance()->info(json_decode($response)->output);
                 } elseif ($info->type == 'error') {
                     // output error info
                     Logger::getInstance()->info($info->message);
                 }
             };
         }
         if (!$failCallback instanceof \Closure) {
             $failCallback = function (\Exception $exception) {
                 Logger::getInstance()->info($exception->getMessage());
             };
         }
         try {
             while ($response = $WSClient->receive()) {
                 $successCallback($response);
             }
         } catch (\Exception $e) {
             $failCallback($e);
         }
         return true;
     }
 }
开发者ID:allansun,项目名称:docker-cloud-php-api,代码行数:63,代码来源:Client.php

示例4: clearUri

 /**
  * Get clear uri.
  *
  * @static
  *
  * @param \Zend\Uri\Uri $uri
  *
  * @return boolean|\Zend\Uri\Uri False if uri is not auhorized
  */
 public static function clearUri(Uri $uri)
 {
     if ($uri->getScheme() !== 'http') {
         return false;
     }
     $uri->setHost('www.vimeo.com');
     // clear
     $uri->setPort(0);
     $uri->setUserInfo('');
     $uri->setQuery('');
     $uri->setFragment('');
     return $uri;
 }
开发者ID:pokap,项目名称:media,代码行数:22,代码来源:Vimeo.php

示例5: clearUri

 /**
  * Get clear uri.
  *
  * @static
  *
  * @param \Zend\Uri\Uri $uri
  *
  * @return boolean|\Zend\Uri\Uri False if uri is not auhorized
  */
 public static function clearUri(Uri $uri)
 {
     if ($uri->getScheme() !== 'http') {
         return false;
     }
     $query = $uri->getQueryAsArray();
     if (empty($query['v'])) {
         return false;
     }
     $uri->setQuery(array('v' => $query['v']));
     $uri->setHost('www.youtube.com');
     $uri->setPath('/watch');
     // clear
     $uri->setPort(0);
     $uri->setUserInfo('');
     $uri->setFragment('');
     return $uri;
 }
开发者ID:pokap,项目名称:media,代码行数:27,代码来源:Youtube.php

示例6: createAuthorizationRequestUri

 /**
  * Generates an URI representing the authorization request.
  *
  * @param Request $request
  * @return string
  */
 public function createAuthorizationRequestUri(Request $request)
 {
     /* @var $clientInfo \InoOicClient\Client\ClientInfo */
     $clientInfo = $request->getClientInfo();
     if (!$clientInfo) {
         throw new \RuntimeException('Missing client info in request');
     }
     if (($endpointUri = $clientInfo->getAuthorizationEndpoint()) === null) {
         throw new Exception\MissingEndpointException('No endpoint specified');
     }
     $uri = new Uri($endpointUri);
     $params = array(Param::CLIENT_ID => $clientInfo->getClientId(), Param::REDIRECT_URI => $clientInfo->getRedirectUri(), Param::RESPONSE_TYPE => $this->arrayToSpaceDelimited($request->getResponseType()), Param::SCOPE => $this->arrayToSpaceDelimited($request->getScope()), Param::STATE => $request->getState());
     foreach ($params as $name => $value) {
         if (in_array($name, $this->requiredParams) && empty($value)) {
             throw new Exception\MissingFieldException($name);
         }
     }
     $uri->setQuery($params);
     return $uri->toString();
 }
开发者ID:publicitas-deployment,项目名称:php-openid-connect-client,代码行数:26,代码来源:Generator.php

示例7: testSetQueryFromArray

 /**
  * Test that we can use an array to set the query parameters
  *
  * @param array  $data
  * @param string $expqs
  * @dataProvider queryParamsArrayProvider
  */
 public function testSetQueryFromArray(array $data, $expqs)
 {
     $uri = new Uri();
     $uri->setQuery($data);
     $this->assertEquals('?' . $expqs, $uri->toString());
 }
开发者ID:navassouza,项目名称:zf2,代码行数:13,代码来源:UriTest.php

示例8: geocode

 /**
  * Execute geocoding
  * 
  * @param  Request $request
  * @return Response
  */
 public function geocode(Request $request)
 {
     if (null === $request) {
         throw new Exception\InvalidArgumentException('request');
     }
     $uri = new Uri();
     $uri->setHost(self::GOOGLE_MAPS_APIS_URL);
     $uri->setPath(self::GOOGLE_GEOCODING_API_PATH);
     $urlParameters = $request->getUrlParameters();
     if (null === $urlParameters) {
         throw new Exception\RuntimeException('Invalid URL parameters');
     }
     $uri->setQuery($urlParameters);
     $client = $this->getHttpClient();
     $client->setAdapter('Zend\\Http\\Client\\Adapter\\Curl');
     $client->resetParameters();
     $uri->setScheme("https");
     $client->setUri($uri->toString());
     $stream = $client->send();
     $body = Json::decode($stream->getBody(), Json::TYPE_ARRAY);
     $hydrator = new ArraySerializable();
     $response = new Response();
     $response->setRawBody($body);
     if (!isset($body['status'])) {
         throw new Exception\RuntimeException('Invalid status');
     }
     $response->setStatus($body['status']);
     if (!isset($body['results'])) {
         throw new Exception\RuntimeException('Invalid results');
     }
     $resultSet = new ResultSet();
     foreach ($body['results'] as $data) {
         $result = new Result();
         $hydrator->hydrate($data, $result);
         $resultSet->addElement($result);
     }
     $response->setResults($resultSet);
     return $response;
 }
开发者ID:shinesoftware,项目名称:GoogleMaps,代码行数:45,代码来源:Geocoder.php

示例9: canonizeUrl

 /**
  * Canonize URL with params, set `appkey` if not specified yet
  *
  * @param string|Uri $uri
  * @param array $params
  *
  * @return Uri
  */
 protected function canonizeUrl($uri, array $params = array())
 {
     if (!$uri instanceof Uri) {
         $uri = new Uri($uri);
     }
     if (!isset($params['appkey'])) {
         $params['appkey'] = Pi::config('identifier');
     }
     $params = array_merge($uri->getQueryAsArray(), $params);
     $uri->setQuery($params);
     return $uri;
 }
开发者ID:Andyyang1981,项目名称:pi,代码行数:20,代码来源:Remote.php

示例10: clearUri

 /**
  * Get clear uri.
  *
  * @static
  *
  * @param \Zend\Uri\Uri $uri
  *
  * @return boolean|\Zend\Uri\Uri False if uri is not auhorized
  */
 public static function clearUri(Uri $uri)
 {
     if ($uri->getScheme() !== 'http') {
         return false;
     }
     $paths = explode('/', $uri->getPath());
     $pathsCount = count($paths);
     if ($pathsCount < 2) {
         return false;
     }
     $type = $paths[$pathsCount - 2];
     if (!in_array($type, self::$typesAuthorized)) {
         return false;
     }
     $uri->setHost('www.deezer.com');
     // clear
     $uri->setPort(0);
     $uri->setUserInfo('');
     $uri->setQuery('');
     $uri->setFragment('');
     return $uri;
 }
开发者ID:pokap,项目名称:media,代码行数:31,代码来源:Deezer.php

示例11: setQuery

 /**
  * Set the query string
  *
  * @param  string|array $query
  * @return \Zend\Uri\Uri
  */
 public function setQuery($query)
 {
     $this->uri->setQuery($query);
     return $this;
 }
开发者ID:sunnyct,项目名称:silexcmf-core,代码行数:11,代码来源:Uri.php


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