javascript - Twitter API user timeline extraction in Node.Js -


i use twit node.js module , while works i'm having 1 problem.

i want able extract tweets made authorized user of app. when authorize in twitter using twit module send following data:

var t = new twit({     consumer_key:         'xxxx'     , consumer_secret:      'xxxx'     , access_token:         'xxxx'     , access_token_secret:  'xxxx' }); 

suppose authorize user through passport module or - data need replace above result want?

thank you!

login twitter, , go dev.twitter.com , find link "manage apps" redirect apps.twitter.com, there find "create new app" button, click on , fill form. after creating app go application created , go "keys , access tokens" tab , click on "generate consumer key , secret" copy "consumer key" "consumer secret" "access token" "access token secret" , put in code.

if using passport authentication use following code logging user's "access token" , "access token secret"

var mongoose = require('mongoose'),     schema = mongoose.schema;  var twitter_consumer_key = "your consumer key got above steps"; var twitter_consumer_secret = "your consumer key secret got above steps ";  var userschema = new schema({ provider: string, uid: string, name: string, image: string, token: string, tokensecret: string, created: {type: date, default: date.now} });  mongoose.connect(mongooseconnectionstring); mongoose.model('user', userschema);  var user = mongoose.model('user');  passport.use(new twitterstrategy({ consumerkey: twitter_consumer_key, consumersecret: twitter_consumer_secret, callbackurl: twittercallbackurl }, function(token, tokensecret, profile, done) { user.findone({uid: profile.id}, function(err, user) { //check if user profile     present in database   if(user) { //if profilie present nothing     done(null, user);   } else {  //else save user profile , tokens in database     var user = new user();     user.provider = "twitter";     user.uid = profile.id;     user.name = profile.displayname;     user.image = profile._json.profile_image_url;     user.token = token;     user.tokensecret = tokensecret;     user.save(function(err) {       if(err) { throw err; }       done(null, user);      });    }   })  } )); 

i supposing passport module can manage rest of code


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -