Latest follower returns unexpected results

I have a script that runs every few seconds and grabs the most recent follower - a limit of 1. It all works well until at a point when a new user follows. The first few requests will return the true most recent follower, however, the third or fourth request will then return the previous most recent follower before going back to the true most recent follower. It then just becomes a constant game of back and forth.

Any idea what gives? Could it be a caching issue on the API call?

$request = $client->get('https://api.twitch.tv/kraken/channels/jonliney/follows?limit=1');

// returns JSON array - this JSON array constantly changes between user's if a new user follows or unfollows

Your requests are probably being served by different processes on the backend with slightly different cached data as “every few seconds” is too quick to query the API for new data. You’re probably going to have to increase that to at least a minute or more.

What george says is correct: Different servers have different cached results. I’d recommend polling at most once per minute and increasing your limit to compensate.

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