Reputation: 221
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?
Upvotes: 6
Views: 7837
Reputation: 251
I was facing the same issue with replying to a particular tweet. Here are sample parameters which resolved my issue:
var username = user.screen_name;
var params= {
in_reply_to_status_id:'715236671738908672',
status:`@${username} ${message}`
}
Where the in_reply_to_status_id
parameter contains a value of id_str
instead of id
of a particular tweet and the status
parameter contains the value of "@"+user.screen_name+"message"
.
Upvotes: 6
Reputation: 85
you should add @username of the replied tweet in the status of the tweet.
Note: This (in_reply_to_status_id) parameter will be ignored unless the author of the Tweet this parameter references is mentioned within the status text. Therefore, you must include @username, where username is the author of the referenced Tweet, within the update.
Upvotes: 5
Reputation: 1193
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) {});
Upvotes: 14