Exemplo n.º 1
0
 /**
  * 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'];
     });
 }
Exemplo n.º 2
0
 /**
  * Send a HTTP GET request to a specific endpoint.
  *
  * @param  string  $endpoint
  * @param  array  $parameters  []
  * @param  array  $headers  []
  * @return \TwitchApi\Contracts\Response
  */
 private function request($method, $endpoint, array $parameters = [], array $headers = [])
 {
     $request = curl_init($endpoint = Application::api() . $endpoint);
     curl_setopt($request, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($request, CURLOPT_SSL_VERIFYPEER, (bool) $this->app->verifypeer);
     if (strtoupper($method) === 'POST') {
         curl_setopt($request, CURLOPT_POST, true);
     }
     if (!empty($parameters)) {
         curl_setopt($request, CURLOPT_POSTFIELDS, $parameters);
     }
     $headers = array_merge($headers, array_filter([$this->app->v3 ? 'Accept: application/vnd.twitchtv.v3+json' : null, 'Client-ID: ' . Application::client()]));
     curl_setopt($request, CURLOPT_HTTPHEADER, $headers);
     $response = curl_exec($request);
     curl_close($request);
     return $this->app->make('TwitchApi\\Contracts\\Response', [$response, ['method' => $method, 'endpoint' => $endpoint, 'parameters' => $parameters, 'headers' => $headers]]);
 }
Exemplo n.º 3
0
 /**
  * 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;
 }
Exemplo n.º 4
0
 /**
  * Create a channel instance.
  *
  * @param  string  $channel
  * @return \TwitchApi\Contracts\Channel
  */
 public function channel($channel)
 {
     return $this->app->make('TwitchApi\\Contracts\\Channel', [$this->user(), $channel]);
 }