I am trying to create a simple json call coupled with an if function to display whether a channel is live or not. I am not a very good developer, but I am trying to make it work for one stream for one site. If someone could point out where my error is, that would be much appreciated. Thank you!
<script src="https://code.jquery.com/jquery-1.11.1.min.js"></script>
<script>
$.getjson('https://api.twitch.tv/kraken/streams/LegacyObserver', function(channel) {
if (channel["stream"] == "null") {
document.write("<img src='/grafx/offline.jpg'>");
} else {
document.write("<img src='/grafx/online.jpg'>");
}
});
</script>