-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
40 lines (34 loc) · 1.12 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
var prompt = require('prompt');
var twitterAPI = require('node-twitter-api');
var twitter = new twitterAPI({
consumerKey: '****************',
consumerSecret: '****************',
callback: 'oob'
});
var token = "";
var tokenSecret = "";
prompt.start();
twitter.getRequestToken(function(error, requestToken, requestTokenSecret, results){
if (error) {
console.log(error);
} else {
token = requestToken;
tokenSecret = requestTokenSecret;
//console.log(token,tokenSecret);
console.log("Please use this links: https://twitter.com/oauth/authenticate?oauth_token="+token);
prompt.get(['code'], function (err, result) {
//console.log('Command-line input received:');
//console.log(' code: ' + result.code);
twitter.getAccessToken(token, tokenSecret, result.code, function(error, accessToken, accessTokenSecret, results) {
if (error) {
console.log(error);
} else {
console.log('Final result:');
console.log(' Username: '+results.screen_name);
console.log(' accessToken: '+accessToken);
console.log(' accessTokenSecret: '+accessTokenSecret);
}
});
});
}
});