-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
36 lines (32 loc) · 937 Bytes
/
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
const Twitter = require("twitter");
const config = require("./config.js");
const T = new Twitter(config);
// Set up your search parameters
const params = {
q: "#reactjs",
count: 10,
result_type: "recent",
lang: "en"
};
// Initiate your search using the above paramaters
T.get("search/tweets", params, (err, data, response) => {
console.log("search");
// 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(
`Favorited: https://twitter.com/${username}/status/${favoritedTweetId}`
);
});
});
});