Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Twitter API reply (in_reply_to_status_id) not working properly

I am using the Twit library to build a Twitter bot in node.js. However, when I want to post a reply to a tweet, it appears, but not in the reply stream.

My code:

twitter.post('statuses/update', { in_reply_to_status_id: data.statuses[0].user.id, status: '@' + data.statuses[0].user.screen_name + ' -some message-' }, function (err, data, res) {});

Where data is a tweet object I got from a search request.

Any help on this?

like image 301
kyr Avatar asked May 20 '14 16:05

kyr


1 Answers

The value for the parameter in_reply_to_status_id must be a Tweet ID to preserve the conversation. You passed here a user ID instead of a Tweet ID.

Also, when working with JavaScript in particular, please make sure you use the stringified IDs id_str instead of id to avoid any integer overflow issues.

As a result, below is the updated line of code with the stringified Tweet ID:

twitter.post('statuses/update', { in_reply_to_status_id: data.statuses[0].id_str, status: '@' + data.statuses[0].user.screen_name + ' -some message-' }, function (err, data, res) {});
like image 198
Romain Huet Avatar answered Oct 13 '22 22:10

Romain Huet