/** * {@inheritdoc} */ public function getRequestTokenEndpoint() { $uri = new Uri($this->baseApiUri . 'oauth/request_token'); $scopes = $this->getScopes(); if (count($scopes)) { $uri->setQuery('scope=' . implode('%20', $scopes)); } return $uri; }
/** * Factory method to build a URI from parts * * @param string $scheme * @param string $userInfo * @param string $host * @param string $port * @param string $path * @param string $query * @param string $fragment * * @return UriInterface */ public function createFromParts($scheme, $userInfo, $host, $port, $path = '', $query = '', $fragment = '') { $uri = new Uri(); $uri->setScheme($scheme); $uri->setUserInfo($userInfo); $uri->setHost($host); $uri->setPort($port); $uri->setPath($path); $uri->setQuery($query); $uri->setFragment($fragment); return $uri; }
/** * Check the authentication. Will be called two times : first to request a token, and redirect * to the Twitter api url, then to authenticate the user. * * @param [type] $request [description] * @param array $options [description] * @return [type] [description] */ public function check($request, array $options = array()) { $here = new Uri($request->to('url')); $here->setQuery(''); $credentials = new Credentials($this->_config['key'], $this->_config['secret'], $here->getAbsoluteUri()); $serviceFactory = new ServiceFactory(); $service = $serviceFactory->createService(static::NAME, $credentials, $this->_storage, $this->_config['scope']); if (empty($request->query['code'])) { $url = $service->getAuthorizationUri(); header('Location: ' . $url); exit(0); } else { $service->requestAccessToken($request->query['code']); $result = json_decode($service->request(static::USER_INFO), true); return $result; } }
/** * @covers OAuth\Common\Http\Uri\Uri::__construct * @covers OAuth\Common\Http\Uri\Uri::parseUri * @covers OAuth\Common\Http\Uri\Uri::setQuery * @covers OAuth\Common\Http\Uri\Uri::getAbsoluteUri */ public function testSetQueryFilled() { $uri = new Uri('http://example.com'); $uri->setQuery('param1=value1¶m2=value2'); $this->assertSame('http://example.com?param1=value1¶m2=value2', $uri->getAbsoluteUri()); }