src/Wrapper.php
public function request($type, $target, $options = [], $authorized = false)
  {
      $headers = [
      'Accept' => 'application/vnd.twitchtv.v3+json',
    ];

      if ($authorized) {
          $headers['Authorization'] = 'OAuth '.$this->accessToken;
      }

      $options = array_merge_recursive(['headers' => $headers], $options);

      try {
          if ($this->throttling) {
              $this->throttle->throttle();
          }

          $response = $this->client->request($type, $this->apiURL.$target, $options);
      } catch (RequestException $e) {
          if ($e->hasResponse()) {
              $response = $e->getResponse();
          } else {
              return;
          }
      }

      $body = json_decode($response->getBody()->getContents());

      return (json_last_error() == JSON_ERROR_NONE) ? $body : $response->getBody()->getContents();
  }
public function request($type, $target, $options = [], $authorized = false)
  {
      $headers = [
      'Accept' => 'application/vnd.twitchtv.v3+json',
    ];

      if ($authorized) {
          $headers['Authorization'] = 'OAuth '.$this->accessToken;
      }

      $options = array_merge_recursive(['headers' => $headers], $options);

      try {
          if ($this->throttling) {
              $this->throttle->throttle();
          }

          $response = $this->client->request($type, $this->apiURL.$target, $options);
      } catch (RequestException $e) {
          if ($e->hasResponse()) {
              $response = $e->getResponse();
          } else {
              return;
          }
      }

      $body = json_decode($response->getBody()->getContents());

      return (json_last_error() == JSON_ERROR_NONE) ? $body : $response->getBody()->getContents();
  }
public function request ( $ type , $ target , $ options = [ ] , $ authorized = false ) { $ headers = [ 'Accept' => 'application/vnd.twitchtv.v3+json' , ] ; if ( $ authorized ) { $ headers [ 'Authorization' ] = 'OAuth ' . $ this -> accessToken ; } $ options = array_merge_recursive ( [ 'headers' => $ headers ] , $ options ) ; try { if ( $ this -> throttling ) { $ this -> throttle -> throttle ( ) ; } $ response = $ this -> client -> request ( $ type , $ this -> apiURL . $ target , $ options ) ; } catch ( RequestException $ e ) { if ( $ e -> hasResponse ( ) ) { $ response = $ e -> getResponse ( ) ; } else { return ; } } $ body = json_decode ( $ response -> getBody ( ) -> getContents ( ) ) ; return ( json_last_error ( ) == JSON_ERROR_NONE ) ? $ body : $ response -> getBody ( ) -> getContents ( ) ; }
Makes a GuzzleHttp request.

@param  requestType  $type       GET, POST, PUT, DELETE
@param  string       $target     Target URL
@param  array        $options    Request options
@param  bool      $authorized Attach Authorization headers

@return array        JsonDecoded body contents
Makes a GuzzleHttp request .