Exemplo n.º 1
0
 protected function getProxiedFuture()
 {
     if (!$this->future) {
         $params = $this->params;
         if (!$this->action) {
             throw new Exception(pht('You must %s!', 'setRawGitHubQuery()'));
         }
         if (!$this->accessToken) {
             throw new Exception(pht('You must %s!', 'setAccessToken()'));
         }
         $uri = new PhutilURI('https://api.github.com/');
         $uri->setPath('/' . ltrim($this->action, '/'));
         $future = new HTTPSFuture($uri);
         $future->setData($this->params);
         $future->addHeader('Authorization', 'token ' . $this->accessToken);
         // NOTE: GitHub requires a 'User-Agent' header.
         $future->addHeader('User-Agent', __CLASS__);
         $future->setMethod($this->method);
         foreach ($this->headers as $header) {
             list($key, $value) = $header;
             $future->addHeader($key, $value);
         }
         $this->future = $future;
     }
     return $this->future;
 }
 protected function getProxiedFuture()
 {
     if (!$this->future) {
         $params = $this->params;
         if (!$this->action) {
             throw new Exception(pht('You must %s!', 'setRawAsanaQuery()'));
         }
         if (!$this->accessToken) {
             throw new Exception(pht('You must %s!', 'setAccessToken()'));
         }
         $uri = new PhutilURI('https://app.asana.com/');
         $uri->setPath('/api/1.0/' . ltrim($this->action, '/'));
         $future = new HTTPSFuture($uri);
         $future->setData($this->params);
         $future->addHeader('Authorization', 'Bearer ' . $this->accessToken);
         $future->setMethod($this->method);
         $this->future = $future;
     }
     return $this->future;
 }
Exemplo n.º 3
0
 protected function getProxiedFuture()
 {
     if (!$this->future) {
         $params = $this->params;
         if (!$this->action) {
             throw new Exception(pht('You must %s!', 'setRawSlackQuery()'));
         }
         if (!$this->accessToken) {
             throw new Exception(pht('You must %s!', 'setAccessToken()'));
         }
         $uri = new PhutilURI('https://slack.com/');
         $uri->setPath('/api/' . $this->action);
         $uri->setQueryParam('token', $this->accessToken);
         $future = new HTTPSFuture($uri);
         $future->setData($this->params);
         $future->setMethod($this->method);
         $this->future = $future;
     }
     return $this->future;
 }
 protected function getProxiedFuture()
 {
     if (!$this->future) {
         $params = $this->params;
         if (!$this->action) {
             throw new Exception("You must setRawWordPressQuery()!");
         }
         if (!$this->accessToken) {
             throw new Exception("You must setAccessToken()!");
         }
         $uri = new PhutilURI('https://public-api.wordpress.com/');
         $uri->setPath('/rest/v1/' . ltrim($this->action, '/'));
         $future = new HTTPSFuture($uri);
         $future->setData($this->params);
         $future->setMethod($this->method);
         // NOTE: This is how WordPress.com REST API authenticates
         $future->addHeader('Authorization', 'Bearer ' . $this->accessToken);
         $this->future = $future;
     }
     return $this->future;
 }
Exemplo n.º 5
0
 protected function getProxiedFuture()
 {
     if (!$this->future) {
         $params = $this->params;
         if (!$this->action) {
             throw new Exception('You must setRawTwitchQuery()!');
         }
         if (!$this->accessToken) {
             throw new Exception('You must setAccessToken()!');
         }
         $uri = new PhutilURI('https://api.twitch.tv/');
         $uri->setPath('/kraken/' . ltrim($this->action, '/'));
         $uri->setQueryParam('oauth_token', $this->accessToken);
         $future = new HTTPSFuture($uri);
         $future->setData($this->params);
         $future->setMethod($this->method);
         // NOTE: This is how the Twitch API is versioned.
         $future->addHeader('Accept', 'application/vnd.twitchtv.2+json');
         // NOTE: This is required to avoid rate limiting.
         $future->addHeader('Client-ID', $this->clientID);
         $this->future = $future;
     }
     return $this->future;
 }