Company logo
  • Empleos
  • Bootcamp
  • Acerca de nosotros
  • Para profesionales
    • Inicio
    • Empleos
    • Cursos y retos
    • Preguntas
    • Profesores
    • Bootcamp
  • Para empresas
    • Inicio
    • Nuestro proceso
    • Planes
    • Pruebas
    • Nómina
    • Blog
    • Calculadora

0

64
Vistas
Twitter api statuses/update throws an error of authorization

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!")
  }
  
}
    
7 months ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar empleo Planes Nuestro proceso Comercial
Legal
Términos y condiciones Política de privacidad
© 2023 PeakU Inc. All Rights Reserved.