/**
  * 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;
 }
 protected function constructRedirectUri($uri = null, array $query = array())
 {
     $uri = new Uri($uri);
     if (!empty($query)) {
         $query = $uri->getQueryAsArray() + $query;
         $uri->setQuery($query);
     }
     return $uri;
 }
Example #3
0
 /**
  * Get Url
  *
  * @return string
  */
 public function getUrl()
 {
     if ($this->uri instanceof Uri) {
         $url = array('href' => $this->uri->toString());
         $query = $this->uri->getQueryAsArray();
         if (sizeof($query) > 0) {
             $url['query'] = $query;
         }
         return $url;
     }
     return;
 }
Example #4
0
 /**
  * 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;
 }
 /**
  * @param $price
  * @return FilterValue|null
  * @throws UnparseableValueException
  */
 public function getValueForPrice($price)
 {
     $values = $this->getFilterValues();
     foreach ($values as $value) {
         $url = $value->getLink();
         $uri = new Uri($url);
         $parts = $uri->getQueryAsArray();
         if (isset($parts['price'])) {
             $priceParts = explode('-', $parts['price']);
             if (!$priceParts[0]) {
                 $priceParts[0] = -1;
             }
             if (!$priceParts[1]) {
                 $priceParts[1] = PHP_INT_MAX;
             }
             // term 0, price filters seem to use less than
             if ($price >= $priceParts[0] & $price < $priceParts[1]) {
                 return $value;
             }
         }
     }
     return null;
 }
Example #6
0
 /**
  * @group ZF-1480
  */
 public function testGetQueryAsArrayReturnsCorrectArray()
 {
     $url = new Uri('http://example.com/foo/?test=a&var[]=1&var[]=2&some[thing]=3');
     $this->assertEquals('test=a&var[]=1&var[]=2&some[thing]=3', $url->getQuery());
     $exp = array('test' => 'a', 'var' => array(1, 2), 'some' => array('thing' => 3));
     $this->assertEquals($exp, $url->getQueryAsArray());
 }
Example #7
0
 /**
  * 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;
 }
Example #8
0
 /**
  * Return the query string as an associative array of key => value pairs
  *
  * @return array
  */
 public function getQueryAsArray()
 {
     return $this->uri->getQueryAsArray();
 }