Show follower count from multiple channels on website

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.

I still can’t get it to work after tweaking for a long time:

$(’.followers’).each(function () {
var tnick = $(this).data(‘tnick’);
var span = $(this).next();
$.get(‘https://api.twitch.tv/kraken/streams’ + tnick , function (data) {
var followers = data.stream.channel.followers;
span.html(followers);
}
);
});

https://jsfiddle.net/45u6nh1h/

You were missing a / in the URL, and the example HTML you gave didn’t contain the followers class anywhere.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.