Flutter
Twitter API authentication and fetching helpers
Managing oauth flow can be a pain and involve a lot of messy code. Flutter helps with that.
Auth flow example
var express = require('express');
var Flutter = require('flutter');
var flutter = new Flutter({
consumerKey: 'MY CONSUMER KEY',
consumerSecret: 'MY CONSUMER SECRET',
loginCallback: 'http://my-host/twitter/callback',
authCallback: function(req, res, next) {
if (req.error) {
return;
}
var accessToken = req.session.oauthAccessToken;
var secret = req.session.oauthAccessTokenSecret;
res.redirect('/back/to/app');
}
});
var app = express();
app.get('/twitter/connect', flutter.connect);
app.get('/twitter/callback', flutter.auth);
Currently only GET
functions are supported
flutter.API.get('search/tweets.json', { q: 'bacon' }, accessToken, secret, function(err, results) {
console.log(results);
});
Options
var flutter = new Flutter({
debug: function(msg){ ... },
consumerKey: 'foo',
consumerSecret: 'bar',
loginCallback: 'http://foo.com/authCallback',
completeCallback: 'http://foo.com/completeCallback',
connectCallback: function(req, res, next){},
authCallback: function(req, res, next){},
cache: 60000,
redis: { host: 'localhost', port: 6379, database: 0, options: {} },
cacheClient: redisClient,
prefix: 'flutter:'
});