Пример #1
0
 public static function codeListener($url_parameters, $redirect_uri, $state = '')
 {
     if (empty($url_parameters['code'])) {
         return;
     }
     $post_data = ['client_id' => Twitch::getClientId(), 'client_secret' => Twitch::getClientSecret(), 'grant_type' => 'authorization_code', 'redirect_uri' => $redirect_uri, 'code' => $url_parameters['code']];
     if (!empty($state)) {
         $post_data['state'] = $state;
     }
     return Twitch::api('oauth2/token')->post($post_data)->data();
 }