Last active
November 23, 2016 06:00
-
-
Save amandeepmittal/7561a0c9c3a81a65bf0a9e1c8294353b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// RETWEET BOT ========================== | |
// find latest tweet according the query 'q' in params | |
var retweet = function() { | |
var params = { | |
q: '#nodejs, #Nodejs', // REQUIRED | |
result_type: 'recent', | |
lang: 'en' | |
} | |
// for more parametes, see: https://dev.twitter.com/rest/reference/get/search/tweets | |
Twitter.get('search/tweets', params, function(err, data) { | |
// if there no errors | |
if (!err) { | |
// grab ID of tweet to retweet | |
var retweetId = data.statuses[0].id_str; | |
// Tell TWITTER to retweet | |
Twitter.post('statuses/retweet/:id', { | |
id: retweetId | |
}, function(err, response) { | |
if (response) { | |
console.log('Retweeted!!!'); | |
} | |
// if there was an error while tweeting | |
if (err) { | |
console.log('Something went wrong while RETWEETING... Duplication maybe...'); | |
} | |
}); | |
} | |
// if unable to Search a tweet | |
else { | |
console.log('Something went wrong while SEARCHING...'); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment