twit sample
| var Twit = require('Twit'); | |
| var config = { | |
| //my config | |
| }; | |
| var T = new Twit(config); | |
| var filterStream; | |
| function filter() { | |
| filterStream = T.stream('statuses/filter', openStreamOptions); | |
| filterStream.on('tweet', function (tweet) { | |
| //cache tweet | |
| removeLastTweetAndNewTweetForOpenStream(tweet); | |
| //emit the single tweet object | |
| log('info', 'information stream received a tweet!'); | |
| eventBus.emit(eventBusKeys.SOCKET_OPENSTREAM_UPDATE, tweet); | |
| }); | |
| filterStream.on('connect', function () { | |
| log('info', 'information stream connecting...'); | |
| }); | |
| filterStream.on('disconnect', function (message) { | |
| log('error', 'information stream disconnected with message: ' + message); | |
| }); | |
| filterStream.on('connected', function (response) { | |
| log('info', 'information stream connected with response: ' + response.statusCode ); | |
| }); | |
| filterStream.on('reconnect', function () { | |
| log('warn', 'information stream reconnecting'); | |
| }); | |
| filterStream.on('warning', function (message) { | |
| log('warn', 'information stream warning: ' + message); | |
| }); | |
| } | |
| module.exports = function () { | |
| filter(); | |
| return { | |
| getCachedOpenStreamTweets: getCachedOpenStreamTweets | |
| } | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment