Last active
November 24, 2016 23:22
-
-
Save TJkrusinski/5536583 to your computer and use it in GitHub Desktop.
Twitter Love/Hate for stack overflow.
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(){ | |
var socket = io.connect('http://localhost:8080'); | |
socket.on('tweet', function(tweet) { | |
$('body').append('<div class="tweet">' + tweet.text + '</div>'); | |
}); | |
}); |
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
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'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment