Permalink
Browse files

docs

  • Loading branch information...
1 parent b5a5d00 commit da734242fb3b814b6ef712fa90aeca73e55d7bbd @masylum committed Nov 7, 2010
Showing with 24 additions and 15 deletions.
  1. +24 −15 Readme.md
View
@@ -15,26 +15,35 @@ 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');
+ var express = require('express'),
+ connect = require('connect');
+
+ // Prevent reap timer
+ var twitterClient = require('./../')('yourKey', 'yourPass', 'http://twitter-js.com:3003/'),
+ app = express.createServer(
+ connect.bodyDecoder(),
+ connect.cookieDecoder(),
+ connect.session()
+ );
+ app.get('/', function (req, res) {
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}});
- }
- );
+ res.render('client.jade', {locals: {token: token}});
});
});
+ app.post('/message', function (req, res) {
+ twitterClient.apiCall('POST', '/statuses/update.json',
+ {token: {oauth_token_secret: req.param('oauth_token_secret'), oauth_token: req.param('oauth_token'), status: req.param('message')}},
+ function (error, result) {
+ res.render('done.jade');
+ }
+ );
+ });
+
+ app.listen(3003);
+
+
## Test
To test and see this module working:

0 comments on commit da73424

Please sign in to comment.