/** * {@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; }
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; } }
/** * Returns the public resource. * * @param string $url url to request. * @param array $options HTTP request options. Keys: query, data, headers. * @param boolean $parseResponse Whether to parse response. * @return mixed the response. */ public function makeRequest($url, $options = array(), $parseResponse = true) { if (stripos($url, 'http') !== 0) { $url = $this->baseApiUrl . $url; } $url = new Uri($url); if (isset($options['query'])) { foreach ($options['query'] as $key => $value) { $url->addToQuery($key, $value); } } $data = isset($options['data']) ? $options['data'] : array(); $method = !empty($data) ? 'POST' : 'GET'; $headers = isset($options['headers']) ? $options['headers'] : array(); $headers = array_merge($this->getProxy()->getExtraApiHeaders(), $headers); $response = $this->getHttpClient()->retrieveResponse($url, $data, $headers, $method); if ($parseResponse) { $response = $this->parseResponseInternal($response); } return $response; }
/** * {@inheritdoc} */ public function request($path, $method = 'GET', $body = null, array $extraHeaders = array()) { $uri = new Uri($this->baseApiUri . $path); $uri->addToQuery('v', $this->apiVersionDate); return parent::request($uri, $method, $body, $extraHeaders); }
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); }
/** * @return UriInterface */ public function getAuthorizationEndpoint() { $url = new Uri($this->service->getAuthorizationEndpoint()); if (isset($this->state) && $this->service->getValidateState()) { $url->addToQuery('state', $this->state->generateId()); } return $url; }
/** * @return string */ public function getAuthorizationEndpoint() { $url = $this->providerOptions['authorize']; if ($this->popupDisplayName !== false && $this->getIsInsidePopup()) { $url = new Uri($url); $url->addToQuery('display', $this->popupDisplayName); $url = $url->getAbsoluteUri(); } return $url; }
/** * Returns the protected resource. * * @param string $url url to request. * @param array $options HTTP request options. Keys: query, data, referer. * @param boolean $parseResponse Whether to parse response. * @return mixed the response. * @throws ErrorException */ public function makeSignedRequest($url, $options = array(), $parseResponse = true) { if (!$this->getIsAuthenticated()) { throw new ErrorException(Yii::t('eauth', 'Unable to complete the signed request because the user was not authenticated.'), 401); } if (stripos($url, 'http') !== 0) { $url = $this->baseApiUrl . $url; } $url = new Uri($url); if (isset($options['query'])) { foreach ($options['query'] as $key => $value) { $url->addToQuery($key, $value); } } $data = isset($options['data']) ? $options['data'] : array(); $method = !empty($data) ? 'POST' : 'GET'; $headers = isset($options['headers']) ? $options['headers'] : array(); $response = $this->getProxy()->request($url, $method, $data, $headers); if ($parseResponse) { $response = $this->parseResponseInternal($response); } return $response; }
/** * @covers OAuth\Common\Http\Uri\Uri::__construct * @covers OAuth\Common\Http\Uri\Uri::parseUri * @covers OAuth\Common\Http\Uri\Uri::hasExplicitPortSpecified */ public function testHasExplicitPortSpecifiedFalse() { $uri = new Uri('http://example.com'); $this->assertFalse($uri->hasExplicitPortSpecified()); }
public function getCorpUserByNameUri($base_url, $session_key, $name, $fieldList) { //https://rest22.bullhornstaffing.com/rest-services/987up/query/CorporateUser?where=name='Stratum API'&fields=id,name,username,enabled&count=500 $uri = new Uri($base_url . "query/CorporateUser"); $uri->addToQuery("BhRestToken", $session_key); $uri->addToQuery("where", "name='" . $name . "'"); $uri->addToQuery("fields", $fieldList); return $uri; }
/** * @param string $url * @param array $options * @param boolean $parseResponse * @param callable $fn * @return mixed * @throws ErrorException */ protected function request($url, $options, $parseResponse, $fn) { if (stripos($url, 'http') !== 0) { $url = $this->baseApiUrl . $url; } $url = new Uri($url); if (isset($options['query'])) { foreach ($options['query'] as $key => $value) { $url->addToQuery($key, $value); } } $data = isset($options['data']) ? $options['data'] : []; $method = !empty($data) ? 'POST' : 'GET'; $headers = isset($options['headers']) ? $options['headers'] : []; $response = $fn($url, $method, $headers, $data); if ($parseResponse) { $response = $this->parseResponseInternal($response); } return $response; }
public function getSearchUri($base_url, $session_key, $query, $count = 1) { //https://rest.bullhorn.com/rest-services/e999/find?query=smith&countPerEntity=3 $uri = new Uri($base_url . "find"); $uri->addToQuery("BhRestToken", $session_key); $uri->addToQuery("query", $query); $uri->addToQuery("countPerEntity", $count); return $uri; }