Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Twitter OAuth support for Node/Express
CoffeeScript JavaScript Shell
tree: c3aef55ecd
Failed to load latest commit information.
examples Begin adding custom Twitter commands
lib [fix] Changed require('sys') to require('util') for compatibility wit…
src Begin adding custom Twitter commands
.gitignore basic API and example working
LICENSE basic API and example working
README Fix link in README example
example.sh basic API and example working
index.js basic API and example working
make.sh Begin adding custom Twitter commands
package.json

README

An easy way to build Twitter apps with Node+Connect+Express.
The library abstracts away the logic of connecting and disconnecting, building
on the oauth library.

It sets up /sessions/login and /sessions/logout paths, as well as a
/sessions/debug path and, under the hood, some other paths.

// MAKE SURE YOU INCLUDE COOKIE PARSER AND SESSION BEFORE THIS LIBRARY
app.use(express.cookieParser());
app.use(express.session({ secret:'randomness' }));
app.use(twitter.middleware({
  consumerKey: 'your-consumer-key',
  consumerSecret: 'your-consumer-secret',
  baseURL: 'http://your-app.com'
}));

app.get('/', function(req, res) {
  if (req.session.twitter) res.send("hi " + req.session.twitter.name);
  else res.send("<a href='/sessions/login'>log in</a>");
});

app.get('/you', function(req, res) {
  twitter.get('http://twitter.com/account/verify_credentials.json', req,
    function(err, data, response) {
      res.send("Twitter says of you: "+sys.inspect(JSON.parse(data)));
    });
});

Right now, you still have to construct the REST path to call.
(https://dev.twitter.com/docs/api) The library may expand to support
key high level abstractions, e.g. twitter.getTimeline(user);

Something went wrong with that request. Please try again.