コード例 #1
0
ファイル: Channel.php プロジェクト: obnoxiousfrog/twitch-api
 /**
  * Get all of the emoticons of a certain channel.
  *
  * @return array
  */
 public function emoticons()
 {
     $endpoint = '/chat/' . $this->channel . '/emoticons';
     $response = $this->app->request()->get($endpoint, [], ['Authorization: OAuth ' . $this->user->accessToken()]);
     return Application::where((array) $response->emoticons, function ($key, $value) {
         return $value['subscriber_only'];
     });
 }
コード例 #2
0
 /**
  * Attempt to authenticate the user.
  *
  * @return boolean
  */
 public function authenticate()
 {
     if (!isset($_REQUEST['code'])) {
         return false;
     }
     $token = $this->app->request()->post('/oauth2/token', ['client_id' => $this->app->client(), 'client_secret' => $this->app->secret(), 'grant_type' => 'authorization_code', 'redirect_uri' => $this->app->redirect(), 'code' => $_REQUEST['code']]);
     if ($token->error) {
         return false;
     }
     $user = $this->app->request()->get('/user', [], ['Authorization: OAuth ' . $token->access_token]);
     if ($user->error) {
         return false;
     }
     return $this->app->instance('TwitchApi\\Contracts\\User', [$token, $user]);
 }
コード例 #3
0
ファイル: User.php プロジェクト: obnoxiousfrog/twitch-api
 /**
  * Check whether the Twitch user is following a certain channel.
  *
  * @param  string  $streamer
  * @return boolean
  */
 public function isFollowing($streamer)
 {
     $endpoint = '/users/' . $this->name() . '/follows/channels/' . strtolower($streamer);
     $response = $this->app->request()->get($endpoint, [], ['Authorization: OAuth ' . $this->accessToken()]);
     return (bool) $response->created_at;
 }