Last active
August 29, 2015 14:05
-
-
Save gkossakowski/c2d573a74f5a693c4160 to your computer and use it in GitHub Desktop.
Asynchronous fetching of tweets from Twitter
This file contains 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
function fetchTweets(username, callback) { | |
jQuery.ajax({ | |
url: "http://api.twitter.com/1/ | |
statuses/user_timeline.json/", | |
type: "GET", | |
dataType: "jsonp", | |
data: { | |
screen_name : username, | |
include_rts : true, | |
count : 5, | |
include_entities : true | |
}, | |
success: callback | |
}) | |
} | |
var processed = 0 | |
var users = ["gkossakowski", "odersky", "adriaanm"] | |
users.forEach(function (user) { | |
console.log("fetching " + user) | |
fetchTweets(user, function(data) { | |
console.log("finished fetching " + user) | |
data.forEach(function (tweet) { | |
console.log("fetched " + tweet.text) | |
}) | |
processed += 1 | |
if (processed == users.length) { | |
console.log("done") | |
} | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment