Skip to content

Instantly share code, notes, and snippets.

@reuniware
Created July 23, 2021 13:59
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 reuniware/6ca52271463bd76cda7f58a4d25a1b0d to your computer and use it in GitHub Desktop.
Save reuniware/6ca52271463bd76cda7f58a4d25a1b0d to your computer and use it in GitHub Desktop.
NodeJS Tweet
function tweet(str) {
if (twitterEnabled === true) {
const Twitter = require('twitter');
const client = new Twitter({
consumer_key: 'MorX5xvqYCSs7IpvOxxxxxxxx',
consumer_secret: 'XtEyoEDcyFTCLjp9kF1SPFr78Jvu1hiaU5yx2mmWVAxxxxxxxx',
access_token_key: '1417457007389515787-9B0TYSJNhTm53Bv6UEjrdTxxxxxxxx',
access_token_secret: 'CVMtV8Mxutexrx9xDRJ3SdYlT3i9PfLzPrqEFxxxxxxxx'
});
client.post('statuses/update', {status: str}, function(error, tweet, response) {
if (!error) {
//console.log(tweet);
}
});
}
}
function strToHashTags(str) {
let strWithHashTags = ''
const words = str.split(' ');
words.forEach(element => {
if (element.length>1) {
strWithHashTags += '#' + element + ' '
}
})
return strWithHashTags
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment