Ben Flowers
Ben Flowers

Reputation: 1554

Twitter api reply to tweet

I'm trying to write a script to reply to a tweet, using the twit npm module. However whenever I pass the in_reply_to_status_id_str or in_reply_to_status_id this seems to be ignored. Not sure what the issue is?

   T.get('search/tweets', { q: `golf since:2011-07-11`, count: 1 }).then(function (response) {

            const userName = response.data.statuses[0].user.screen_name;
            const tweetId = response.data.statuses[0].id_str;

            T.post('statuses/update', { in_reply_to_status_id_str: tweetId, status: `@${userName}, I like golf too` }, (err, data, response) => {
              resolve()
            })
          })

        })

Upvotes: 5

Views: 4860

Answers (1)

ryanHasStack
ryanHasStack

Reputation: 61

You should be passing the param as in_reply_to_status_id instead of in_reply_to_status_id_str.

T.get('search/tweets', { q: `golf since:2011-07-11`, count: 1 }).then(function (response) {

            const userName = response.data.statuses[0].user.screen_name;
            const tweetId = response.data.statuses[0].id_str;

            T.post('statuses/update', { in_reply_to_status_id: tweetId, status: `@${userName}, I like golf too` }, (err, data, response) => {
              resolve()
            })
          })

        })

Upvotes: 6

Related Questions