コード例 #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
ファイル: Request.php プロジェクト: obnoxiousfrog/twitch-api
 /**
  * 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]]);
 }
コード例 #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;
 }
コード例 #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]);
 }