Skip to content

Instantly share code, notes, and snippets.

@amandeepmittal
Last active November 23, 2016 06:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amandeepmittal/7561a0c9c3a81a65bf0a9e1c8294353b to your computer and use it in GitHub Desktop.
Save amandeepmittal/7561a0c9c3a81a65bf0a9e1c8294353b to your computer and use it in GitHub Desktop.
// 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