Permalink
Browse files

fixed docs

  • Loading branch information...
1 parent 0afde6e commit 0ce46d268de1d2313bf7f4e4aa9e20eb6e82745a @masylum committed Oct 18, 2010
Showing with 19 additions and 17 deletions.
  1. +19 −17 Readme.md
View
36 Readme.md
@@ -2,27 +2,29 @@
Easy peasy twitter client
+ npm install twitter-js
+
## Usage
twitter-js has two methods.
*getAccesToken*: Uses oAuth module to retrieve the access_token
*apiCall*: Does a call to twitter API.
-## Example
-
- var twitterClient = require('twitter-js').twitterClient('consumerKey', 'consumerSecret');
-
- twitterClient.getAccessToken({
- redirect_uri: '/auth/twitter',
- code: req.param('code'),
- },
- function (error, token) {
- if (token) {
- facebookClient.graphCall('GET', 'me', {access_token: token.access_token}, function (error, result) {
- sys.puts(sys.inspect(result));
- });
- }
- }
- );
-
+## Example using express.js
+
+ app.post('/tweet/:message', function (req, res) {
+ var self = this,
+ twitterClient = require('twitter-js').twitterClient('consumerKey', 'consumerSecret');
+
+ twitterClient.getAccessToken(req, res, function (error, token) {
+ twitterClient.apiCall(
+ 'POST',
+ '/statuses/update.json',
+ { token: {oauth_token_secret: token.oauth_token, oauth_token: token.oauth_token_secret}, status: req.param('message') },
+ function (error, result) {
+ res.render('tweet.jade', {locals: {result: result}});
+ }
+ );
+ });
+ });

0 comments on commit 0ce46d2

Please sign in to comment.