public
Last active

Twitter Love/Hate for stack overflow.

  • Download Gist
client.js
JavaScript
1 2 3 4 5 6
$(function(){
var socket = io.connect('http://localhost:8080');
socket.on('tweet', function(tweet) {
$('body').append('<div class="tweet">' + tweet.text + '</div>');
});
});
server.js
JavaScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
var express = require('express')
, app = express()
, http = require('http')
, server = http.createServer(app)
, Twit = require('twit')
, io = require('socket.io').listen(server);
 
server.listen(8080);
 
// routing
app.get('/', function (req, res) {
res.sendfile(__dirname + '/index.html');
});
 
var watchList = ['love', 'hate'];
 
var T = new Twit({
consumer_key: ''
, consumer_secret: ''
, access_token: ''
, access_token_secret: ''
});
 
T.stream('statuses/filter', { track: watchList },function (stream) {
stream.on('tweet', function (tweet) {
io.sockets.emit('tweet', tweet.text);
console.log(tweet.text);
});
});
 
io.sockets.on('connection', function (socket) {
console.log('Connected');
});

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.