forked from aszantu/100daysofcode-bot
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapp.js
More file actions
36 lines (30 loc) · 908 Bytes
/
app.js
File metadata and controls
36 lines (30 loc) · 908 Bytes
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
const Twitter = require('twitter');
const config = require('./config.js');
const T = new Twitter(config);
// Set up your count and search parameters
const params = {
q: '#100daysofcode',
count: 8,
result_type: 'recent',
lang: 'en'
}
// Initiate your search using the above parameters
T.get('search/tweets', params, (err, data, response) => {
// If there is no error, proceed
if(err){
return console.log(err);
}
// Loop through the returned tweets
const tweetsId = data.statuses
.map(tweet => ({ id: tweet.id_str }));
tweetsId.map(tweetId => {
T.post('favorites/create', tweetId, (err, response) => {
if(err){
return console.log(err[0].message);
}
const username = response.user.screen_name;
const favoritedTweetId = response.id_str;
console.log(`Liked: https://twitter.com/${username}/status/${favoritedTweetId}`);
});
});
})