Using PHP to echo the followers I have. Stuck at 100?

Hi All,

Writing my own control panel for my personal use (To integrate YouTube and Twitch together).

Having an issues with using Foreach to echo out my followers. (That being said I can’t find anything in the API to echo them?)

E.G:

<?php $json = json_decode(file_get_contents("https://api.twitch.tv/kraken/channels/greatbritishbg/follows")); ?>

That shows all the people I have following me, but I read it caps at 100.

Is there anyway and I can remove this cap or work around it?

Thanks

There is a cap because it would be a huge request to the server to output all of the followers for certain streams. Keep in mind that some channels have more than 400 000 followers. As a workaround, you can set a few parameters to your request, such as ?direction=ASC&limit=100&offset=0 (Documentation) and get the first page, and then you change the offset to get the second page, and so on. I would suggest to check if a certain viewer is a follower only when it’s required.

Thanks,
Schmoopiie!

I have written a library to aid people in calling information from the API, found here.

You can use this to do all of the heavy lifting in calling to the API, even going as far as to perform limitless calls to endpoints such as followers of a channel (I have tested it on a channel with 130,000+ followers and it was able to succeed [That being said, I had to add some changes to the environment vars in PHP to accomplish this, primarily the maximum memory of a single script and the script execution time]). Currently supports all of V3 and should be 100% compatible with V2 (I simply return data for the most part, and I do many safety checks to prevent issues from occurring).

Hey Schmoopiie, I was wondering if you knew of any way of making it automatically add pages until the cap was reached? Or is it really a manual jobbie?

Thanks

Not sure to understand your question,

If you plan on using pagination, get the total followers of the channel and use this value to know how many pages are required. For instance, if you want to display 25 results per page and the channel has 75 followers, all you need to do is a simple division, 75 / 25 = 3 pages.

Thanks,
Schmoopiie!