Exemplo n.º 1
0
 /**
  * Create a new instance.
  *
  * @param  string  $client
  * @param  string  $secret
  * @param  array  $scopes
  * @param  string  $redirect
  */
 public function __construct($client, $secret, array $scopes, $redirect)
 {
     static::$client = $client;
     static::$secret = $secret;
     static::$scopes = $scopes;
     static::$redirect = $redirect;
     $this->bind('TwitchApi\\Contracts\\Request', 'TwitchApi\\Request');
     $this->bind('TwitchApi\\Contracts\\Response', 'TwitchApi\\Response');
     $this->bind('TwitchApi\\Contracts\\User', 'TwitchApi\\User');
     $this->bind('TwitchApi\\Contracts\\Channel', 'TwitchApi\\Channel');
 }
Exemplo n.º 2
0
 public static function redirect($url, $permanent = false)
 {
     if (!static::$initialized) {
         static::initialize();
     }
     $url = parse_url($url, PHP_URL_HOST) ? $url : static::$baseUrl . $url;
     $status = $permanent ? 301 : 302;
     if (Debugger::$enabled) {
         Debugger::set('redirect', $url);
         Debugger::set('status', $status);
         Debugger::end('redirect');
     }
     if (static::$executeRedirect) {
         die(header("Location: {$url}", true, $permanent ? 301 : 302));
     } else {
         static::$redirect = $url;
     }
 }
Exemplo n.º 3
0
 /**
  * Convenience function to create a 302 response
  * @see Response::redirect()
  * @static
  * @param string $url The url to redirect to
  * @param boolean $externalRedirect Treat the redirect as external
  * @return Response HTTP 302 Response with URL
  */
 public static function temporaryRedirect($url, $externalRedirect = false)
 {
     /** @var Response $response */
     $response = new static();
     $response->redirect($url, $externalRedirect, self::HTTP_TEMPORARY_REDIRECT);
     return $response;
 }