Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Easy peasy twitter client for connect

tree: 5d9500a15e

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 lib
Octocat-spinner-32 Readme.md
Octocat-spinner-32 index.js
Octocat-spinner-32 package.json
Readme.md

twitter-js

Easy peasy twitter client for connect.

npm install twitter-js

Usage

twitter-js has two methods.

  • getAccesToken(req, res, callback): Uses oAuth module to retrieve the access_token
  • apiCall(http_method, path, params, callback): Does a call to twitter API.

Params must contain the token.

Example using express.js

// You need sessions
app.configure(function () {
  app.use(connect.cookieDecoder());
  app.use(connect.session());
});

app.post('/tweet/:message', function (req, res) {
  var self = this,
      twitterClient = require('twitter-js')('consumerKey', 'consumerSecret');

  twitterClient.getAccessToken(req, res, function (error, token) {
    twitterClient.apiCall('POST', '/statuses/update.json',
      {token: token, status: req.param('message')},
      function (error, result) {
        res.render('tweet.jade', {locals: {result: result}});
      }
    );
  });
});
Something went wrong with that request. Please try again.