protected function init($callbackUrl = null) { if (!$this->init) { if (!$this->storage) { $this->storage = new Session(); } $uriFactory = new UriFactory(); $this->currentUri = $uriFactory->createFromSuperGlobalArray($_SERVER); $credentials = new Credentials($this->apiKey, $this->apiSecret, $callbackUrl ? $callbackUrl : $this->currentUri->getAbsoluteUri()); $serviceFactory = new ServiceFactory(); $serviceFactory->setHttpClient(new CurlClient()); $serviceFactory->registerService('DoYouBuzz', 'DoYouBuzz\\ApiHelper\\DoYouBuzzService'); $this->service = $serviceFactory->createService('DoYouBuzz', $credentials, $this->storage); $this->init = true; } }
/** * 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; } }
private function getServiceObject() { $oUrl = new Uri(BX_DOL_URL_STUDIO . 'store.php?page=purchases'); $oCredentials = new Credentials($this->sKey, $this->sSecret, $oUrl->getAbsoluteUri()); $oServiceFactory = new ServiceFactory(); return $oServiceFactory->createService($this->sService, $oCredentials, $this->oStorage); }
/** * @covers OAuth\Common\Http\Uri\Uri::__construct * @covers OAuth\Common\Http\Uri\Uri::parseUri * @covers OAuth\Common\Http\Uri\Uri::setHost * @covers OAuth\Common\Http\Uri\Uri::getAbsoluteUri */ public function testSetHost() { $uri = new Uri('http://example.com'); $uri->setHost('pieterhordijk.com'); $this->assertSame('http://pieterhordijk.com', $uri->getAbsoluteUri()); }