I am building a bot on twitter with javascript to send a post from my own twitter account. But I am getting the following error:
{
code: 220,
message: 'Your credentials do not allow access to this resource.'
}
I am not using OAuth since I will be the only user of this bot, I just want to send a twitter post inside a certain listener that watches for some event. Here is the inside of my function to send a post on twitter:
const Twitter = require('twitter')
const client = new Twitter({
consumer_key: process.env.TWITTER_CONSUMER_KEY,
consumer_secret: process.env.TWITTER_CONSUMER_SECRET,
access_token_key: process.env.TWITTER_ACCESS_TOKEN_KEY,
access_token_secret: process.env.TWITTER_ACCESS_TOKEN_SECRET,
bearer_token: process.env.TWITTER_BEARER_TOKEN
})
async function sendTwitterPost() {
try {
const response = await client.post('statuses/update', {
status: 'Event occured!',
})
console.log(response)
console.log("Success")
}
catch(err){
console.log(err)
console.log("ERROR WHILE SENDING TWITTER POST!")
}
}