Created
July 23, 2021 13:59
-
-
Save reuniware/6ca52271463bd76cda7f58a4d25a1b0d to your computer and use it in GitHub Desktop.
NodeJS Tweet
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
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