Tuesday, 2 May 2017

Is there a way to reply to a specific tweet using the Twit API?

In the twitter dev docs it references that you can include the tweet ID inside of the in_reply_to_status_id property, of the tweet you want to reply to. I have done that, and my tweet indeed sends out, but NOT as a direct reply to the particular tweet. Is there something I'm missing?

Also, I have console.logged response.context.incomingDirectTweet and it is the correct ID of the tweet that we want to respond to, so all good on that end.

const respondToTweet = function (response) {
    var context = response.context || {};
    const params = { status: response.output.text, in_reply_to_status_id: response.context.incomingDirectTweet }
    T.post('statuses/update', params, function(err, data, response) {
        if (err) {console.log(err)}
    })
}

In case this matters:

const T = new Twit({
  consumer_key:         process.env.consumer_key,
  consumer_secret:      process.env.consumer_secret,
  access_token:         process.env.access_token,
  access_token_secret:  process.env.access_token_secret,
  timeout_ms:           60*1000, 
});



via Aljosha Novakovic

No comments:

Post a Comment