コード例 #1
0
 /**
  * {@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);
 }
コード例 #2
0
 /**
  * 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;
 }
コード例 #3
0
ファイル: Service.php プロジェクト: asratnani/yii2-eauth
 /**
  * @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;
 }
コード例 #4
0
ファイル: ServiceProxy.php プロジェクト: fogunkoya/yii2-eauth
 /**
  * @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;
 }
コード例 #5
0
ファイル: ServiceBase.php プロジェクト: fogunkoya/yii2-eauth
 /**
  * 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;
 }
コード例 #6
0
ファイル: UriTest.php プロジェクト: Flesh192/magento
 /**
  * @covers OAuth\Common\Http\Uri\Uri::__construct
  * @covers OAuth\Common\Http\Uri\Uri::parseUri
  * @covers OAuth\Common\Http\Uri\Uri::addToQuery
  * @covers OAuth\Common\Http\Uri\Uri::getAbsoluteUri
  */
 public function testAddToQueryCreate()
 {
     $uri = new Uri('http://example.com');
     $uri->addToQuery('param1', 'value1');
     $this->assertSame('http://example.com?param1=value1', $uri->getAbsoluteUri());
 }
コード例 #7
0
 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;
 }
コード例 #8
0
ファイル: ServiceBase.php プロジェクト: serker72/cross-stitch
 /**
  * @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;
 }
コード例 #9
0
 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;
 }