Created
February 6, 2016 05:54
-
-
Save copygirl/e6549a4e280df0517851 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var beam = { | |
"channelID": 38756, | |
"getFollowers": function(limit) { | |
return $.getJSON("https://beam.pro/api/v1/channels/" + beam.channelID).promise() | |
.then(function(channelData) { | |
return (function getFollowers(numFollowers, count, followers, page) { | |
var limit = Math.min(count, 100); | |
if (page == null) page = Math.floor(numFollowers / limit); | |
return $.getJSON("https://beam.pro/api/v1/channels/" + beam.channelID + | |
"/follow?page=" + page + "&limit=" + limit + "&fields=username").promise() | |
.then(function(followerData) { | |
for (var i = followerData.length - 1; i >= 0; i--) | |
if (followers.push(followerData[i].username) >= count) return followers; | |
if (--page < 0) return followers; | |
return getFollowers(numFollowers, count, followers, page); | |
}); | |
}(channelData.numFollowers, limit, [ ])); | |
}); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment