Twitch channel status online or offline

Hey guys, I would like to ask for help. I’m trying to get it to work, but with the new twitch api i don’t know how & what to edit or add.

There is .js file which contains:
$(document).ready(function() {

$("#chg").click(function() {
    var name = document.getElementById("input").value;
    name = name.toLowerCase();
    getChannelInfo(name);
    isOnline(name);
});

function getChannelInfo(username) {
    var url = 'https://api.twitch.tv/kraken/channels/' + username;
    $.ajaxSetup({
       headers : {
'Client-ID': 'xxxxxxxxxxxxxxxxxxxxxxxxxxx' //bad
       }
    });        
    $.getJSON(url, function(object) {
        var iconUrl = object.logo;
        if(iconUrl !== null){$("#logo").attr("src", iconUrl);}
      else {$("#logo").attr("src","https://static-cdn.jtvnw.net/jtv_user_pictures/xarth/404_user_150x150.png")}
        $("#channel").html(object.display_name);
    })
    .fail(function() {
        $("#channel").html(username + " not found");
        $("#game").html("");
        $("#title").html("");
      $("#logo").attr("src","https://static-cdn.jtvnw.net/jtv_user_pictures/xarth/404_user_150x150.png")
      $("#status").html("")
      
    });
}

function isOnline(username) {
    var streamUrl = " https://api.twitch.tv/kraken/streams/"+username;
    $.getJSON(streamUrl, function(obj) {
      if(obj.stream !== null){
        if(obj.stream.game !== null) {
             var link = "https://twitch.tv/"+username;
            $("#game").html("" + obj.stream.game +"");
            $("#status").html("LIVE");
            $("#title").html(obj.stream.channel.status)
        }
        
      }
       else {
         $("").html("OFFLINE");
         $("#game").html("");
         $("#title").html("");
       } 
    });
}

getChannelInfo(“dreamhackcs”);
isOnline(“dreamhackcs”);
});

And in the .html file there is script /script command.

(function() {
  var user_name, api_key, twitch_widget;

  user_name = "dreamhackcs";
  api_key = "xxxxxxxxxxxxxxxxxxxxxxxxxx";
  twitch_widget = $("#dreamhack_twitch-widget");
  limit = "1"

  twitch_widget.attr("href","https://twitch.tv/" + user_name);

  $.getJSON('https://api.twitch.tv/kraken/streams/' + user_name + '?client_id=' + api_key + '&callback=?', function(data) {	
      if (data.stream) {
          twitch_widget.html("<span class='online'></span> " + data.stream.viewers);
      } else {
          twitch_widget.html(" OFFLINE");
      }  
  });
})();

I would be very grateful if anyone could help me :slight_smile:

You asked the same question here

This is a duplicate post/a modification of that post.

You already have all the information you need to get online/offline status

Please extend that post if you have an additional query.