Twitch Streaming API
HTML
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<div id="title">
Twitch Streamers Online NOW
</div>
<ul id ="streamers">
</ul>
CSS
.logo {
max-width: 100px;
}
ul
{
list-style-type: none;
}
JavaScript
var channels = ["ESL_SC2", "OgamingSC2", "cretetion", "storbeck", "habathcx"];
function getChannelInfo() {
channels.forEach(function(channel) {
function makeURL(type, userName) {
return 'https://wind-bow.gomix.me/twitch-api/' + type + '/' + userName;
};
$.getJSON(makeURL("streams", channel), function(data) {
console.log(data);
if (data.stream != null){
$('#streamers').append('<li>' + '<img class="logo" src="' + data.stream.channel.logo + '"/>'+ channel + ' is playing ' + data.stream.game);
}
});
});
}
$(document).ready(function(){
getChannelInfo();
});