/** * 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]]); }
/** * 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]); }