Skip to content

Instantly share code, notes, and snippets.

@harthur
Created October 25, 2011 19:25
tweets.js
var ntwitter = require("ntwitter"),
growl = require("growl");
var twitter = new ntwitter({
// fill in w/ keys from https://dev.twitter.com/apps/new
consumer_key: null,
consumer_secret: null,
access_token_key: null,
access_token_secret: null
});
var opts = {
track: '#wwcode'
}
twitter.stream('statuses/filter', opts, function(stream) {
stream.on('data', function(data) {
// called when a new tweet comes in
growl.notify(data.text, {
image: 'wwcode.png',
title: '@' + data.user.screen_name
});
});
console.log("listening for tweets...");
});

How I did it

setup

  • install node
  • install node's package manager, npm

installing packages

  • search nipster for "twitter" and "growl" packages
  • npm install ntwitter
  • npm install growl
  • check out the docs for ntwitter and growl

making the script

  • get some API keys for a new Twitter app
  • code up tweets.js
  • node tweets.js
  • get growl notifications when there's a #wwcode tweet!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment