public function sendRequest($type = 'GET', $path = '', $token = false, $options = [], $availableOptions = [])
    {

/**
 * TODO: $availableOptions is currently not being used, as it's
 * just a limitation in case Twitch adds to, or makes changes to them.
 * This variable can either be removed completed or used for something
 * more useful, like telling developers what options they have.
 */
        // URL parameters
        //$path = $this->generateUrl($path, $token, $options, $availableOptions);
        $path = $this->generateUrl($path, $token, $options, $availableOptions);

        // Headers
        $data = [
          'headers' => [
            'Client-ID' => $this->getClientId(),
            'Accept' => 'application/vnd.twitchtv.v5+json',
          ],
        ];

        // Twitch token
        if ($token) {
            $data['headers']['Authorization'] = 'OAuth '.$this->getToken($token);
        }

        try{
            // Request object
            $request = new Request($type, $path, $data);
            // Send request
            $response = $this->client->send($request);

            // Return body in JSON data
            return json_decode($response->getBody(), true);
        }
        catch(RequestException $e){
            if ($e->hasResponse()) {
                $exception = (string) $e->getResponse()->getBody();
                $exception = json_decode($exception);
                return $exception;
            } else {
                //503
                return array(
                    'error' => 'Service Unavailable',
                    'status' => 503,
                    'message' => $e->getMessage()
                );
            }
        }
        
    }
public function sendRequest($type = 'GET', $path = '', $token = false, $options = [], $availableOptions = [])
    {

/**
 * TODO: $availableOptions is currently not being used, as it's
 * just a limitation in case Twitch adds to, or makes changes to them.
 * This variable can either be removed completed or used for something
 * more useful, like telling developers what options they have.
 */
        // URL parameters
        //$path = $this->generateUrl($path, $token, $options, $availableOptions);
        $path = $this->generateUrl($path, $token, $options, $availableOptions);

        // Headers
        $data = [
          'headers' => [
            'Client-ID' => $this->getClientId(),
            'Accept' => 'application/vnd.twitchtv.v5+json',
          ],
        ];

        // Twitch token
        if ($token) {
            $data['headers']['Authorization'] = 'OAuth '.$this->getToken($token);
        }

        try{
            // Request object
            $request = new Request($type, $path, $data);
            // Send request
            $response = $this->client->send($request);

            // Return body in JSON data
            return json_decode($response->getBody(), true);
        }
        catch(RequestException $e){
            if ($e->hasResponse()) {
                $exception = (string) $e->getResponse()->getBody();
                $exception = json_decode($exception);
                return $exception;
            } else {
                //503
                return array(
                    'error' => 'Service Unavailable',
                    'status' => 503,
                    'message' => $e->getMessage()
                );
            }
        }
        
    }
public function sendRequest ( $ type = 'GET' , $ path = '' , $ token = false , $ options = [ ] , $ availableOptions = [ ] ) { /**
 * TODO: $availableOptions is currently not being used, as it's
 * just a limitation in case Twitch adds to, or makes changes to them.
 * This variable can either be removed completed or used for something
 * more useful, like telling developers what options they have.
 */ // URL parameters //$path = $this->generateUrl($path, $token, $options, $availableOptions); $ path = $ this -> generateUrl ( $ path , $ token , $ options , $ availableOptions ) ; // Headers $ data = [ 'headers' => [ 'Client-ID' => $ this -> getClientId ( ) , 'Accept' => 'application/vnd.twitchtv.v5+json' , ] , ] ; // Twitch token if ( $ token ) { $ data [ 'headers' ] [ 'Authorization' ] = 'OAuth ' . $ this -> getToken ( $ token ) ; } try { // Request object $ request = new Request ( $ type , $ path , $ data ) ; // Send request $ response = $ this -> client -> send ( $ request ) ; // Return body in JSON data return json_decode ( $ response -> getBody ( ) , true ) ; } catch ( RequestException $ e ) { if ( $ e -> hasResponse ( ) ) { $ exception = ( string ) $ e -> getResponse ( ) -> getBody ( ) ; $ exception = json_decode ( $ exception ) ; return $ exception ; } else { //503 return array ( 'error' => 'Service Unavailable' , 'status' => 503 , 'message' => $ e -> getMessage ( ) ) ; } } }
Send request to Twitch API.

@param string $type             Request type
@param string $path             Request URL path
@param bool   $token            Twitch token
@param array  $options          URL queries
@param array  $availableOptions Available URL queries

@return JSON JSON object from Twitch
Send request to Twitch API .