Skip to content

Instantly share code, notes, and snippets.

@voodootikigod
Created November 17, 2009 01:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save voodootikigod/236528 to your computer and use it in GitHub Desktop.
Save voodootikigod/236528 to your computer and use it in GitHub Desktop.
var sys=require('sys'), http = require('http');
var target = "jsconf";
var connection = http.createClient(80, "search.twitter.com");
var since = 0;
function getTweets() {
var request = connection.request('GET', "/search.json?q=" + target + "&since_id="+since, {"host": "search.twitter.com", "User-Agent": "NodeJS HTTP Client"});
request.addListener("response", function(response) {
var responseBody = "";
response.setBodyEncoding("utf8");
response.addListener("data", function(chunk) { responseBody += chunk });
response.addListener("end", function() {
tweets = JSON.parse(responseBody);
var results = tweets["results"],
length = results.length;
for (var i = (length-1); i >= 0; i--) {
if (results[i].id > since) {
since = results[i].id;
}
sys.puts("From " + results[i].from_user + ": " + results[i].text);
}
});
});
request.close();
setTimeout(getTweets, 10000);
};
getTweets();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment