Can someone help me with a simple request that can show a follower count for multiple channels on my website. I am thinking something like this: https://github.com/Fugiman/Twitch-Channel-Status , just with followers instead where I put a html tag the place the count should show up.
EDIT:
I have tried this but it doesn’t seem to work:
$('.followers').each(function () {
var tnick = $(this).data('tnick');
var span = $(this).next();
$.getJSON('https://api.twitch.tv/kraken/streams/' + tnick + '.json?callback=?', function (data) {
var followers = data.followers;
span.html(followers);
}
});
});
And HTML:
p>i data-tnick=“GamerHuset” class=“fa fa-eye views”> span>0/span>/p>
The syntax errors (missing “<”) in the HTML is made on purpose as it wouldn’t show the code.
The follower count is within the channel object inside the stream object, not the data object. You would use data.stream.channel.followers to access it.
Additionally, do not append Twitch API endpoints with .json as it’s unnecessary.