Skip to content

Instantly share code, notes, and snippets.

@xaviervia
Created April 10, 2013 00:13
Show Gist options
  • Save xaviervia/5350602 to your computer and use it in GitHub Desktop.
Save xaviervia/5350602 to your computer and use it in GitHub Desktop.
Connect to twitter streaming API using mTwitter
var twitter = require('mtwitter');
var twit = new twitter({
consumer_key: 'YOURS',
consumer_secret: 'YOURS',
access_token_key: 'YOUR_USERS',
access_token_secret: 'YOUR_USERS'
});
twit.stream(
'statuses/filter',
{track: ['hello'], stall_warnings: 'true'},
function(stream) {
stream.on('data', function (data) {
console.log(data.text);
});
stream.on('end', function(response) {
console.log("end")
});
stream.on('destroy', function(response) {
console.log("destroy")
});
// Disconnect stream after five seconds
//setTimeout(stream.destroy, 5000);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment