Replying to a tweet

replies

#1

How can I reply to a tweet through my application. Can I reply to a tweet if I have the tweet ID? am using “twit” : “2.2.5”


#2

Yes, you’ll need to use the in_reply_to_status_id field when you call POST statuses/update, and the user’s @handle in the text field.


#3

var params = {
status: '@cathy_ioc Hi, this is my reply. I am fine. Thank you!! ',
// use id_str as 'in_reply_to_status_id’
in_reply_to_status_id_str: ‘XXxxxxXXXXXXXXXXXXXXXXXX’
};
T.post(‘statuses/update’, params, function (err, data, response) {
console.log(data)
})

Should the above code do the job? When I run the above code in node.js ,I see that there is a new tweet to @cathy_ioc handle whereas am looking for a way to reply to a particular tweet. Please help


#4

Does the existing Tweet ID you’re replying to exist? Something like that should work but I’ve not tried it myself.


#5

That Tweet ID exists and infact is something that is returned in the json when I execute the search API using the following code
T.get(‘search/tweets’, { q: ‘@cathy_oic’, count: 100, count: 100 }, function(err, data, response) {
console.log(data);
}
the tweet id comes as id_str: ‘800613048289529856’,


#6

When I try to retrieve that Tweet ID it does not exist. I’m also unable to find a user account with that handle.

The method you’re using to reply to a Tweet in general should work as you’ve written it above. You’d see the in_reply_to_status_id, in_reply_to_user_id and in_reply_to_screen_name fields populated inside the resulting reply Tweet.


#7

Andy, Thx for testing the code.They had to disable my account as we we spoke.


#8

Andy, this is the tweet id am trying to reply to… 800604166250897408


#9

And this is the response I get when I try to post a reply to the tweet - whose Id I have just posted

{ created_at: ‘Mon Nov 21 16:23:51 +0000 2016’,
id: 800736491093659600,
id_str: ‘800736491093659648’,
text: ‘@cathy_oic Hi,reply 2’,
truncated: false,
entities:
{ hashtags: [],
symbols: [],
user_mentions: [ [Object] ],
urls: [] },
source: ‘CathyWatsonApplication’,
in_reply_to_status_id: null,
in_reply_to_status_id_str: null,
in_reply_to_user_id: 800604166250897400,
in_reply_to_user_id_str: ‘800604166250897408’,
in_reply_to_screen_name: ‘cathy_oic’,
user:
{ id: 800681258485284900,
id_str: ‘800681258485284864’,
name: ‘PallaviNishtala’,
screen_name: ‘palnishtala’,
location: ‘’,
description: ‘’,
url: null,
entities: { description: [Object] },
protected: false,
followers_count: 0,
friends_count: 0,
listed_count: 0,
created_at: ‘Mon Nov 21 12:44:22 +0000 2016’,
favourites_count: 0,
utc_offset: -28800,
time_zone: ‘Pacific Time (US & Canada)’,
geo_enabled: false,
verified: false,
statuses_count: 3,
lang: ‘en’,
contributors_enabled: false,
is_translator: false,
is_translation_enabled: false,
profile_background_color: ‘F5F8FA’,
profile_background_image_url: null,
profile_background_image_url_https: null,
profile_background_tile: false,
profile_image_url: ‘http://abs.twimg.com/sticky/default_profile_images/default_profile_2_normal.png’,
profile_image_url_https: ‘https://abs.twimg.com/sticky/default_profile_images/default_profile_2_normal.png’,
profile_link_color: ‘1DA1F2’,
profile_sidebar_border_color: ‘C0DEED’,
profile_sidebar_fill_color: ‘DDEEF6’,
profile_text_color: ‘333333’,
profile_use_background_image: true,
has_extended_profile: false,
default_profile: true,
default_profile_image: true,
following: false,
follow_request_sent: false,
notifications: false,
translator_type: ‘none’ },
geo: null,
coordinates: null,
place: null,
contributors: null,
is_quote_status: false,
retweet_count: 0,
favorite_count: 0,
favorited: false,
retweeted: false,
lang: ‘tl’ }


#10

what would be the right call to fetch tweets for a particular handle


#11

Hi Andy, Its been three days since I am trying to reply to a tweet using Twit package of node.js. I have not been able to do this. I have included the code snippets above, and I could include them again. Can you please help here…


#12

The tweet ids look wrong:

id: 800736491093659600,
id_str: '800736491093659648',

javascript (nodejs) has problems with 64 bit integers - https://dev.twitter.com/overview/api/twitter-ids-json-and-snowflake

You may need to fix that first, it could be that it’s trying to reply to the wrong tweet id because of this limitation.


#13

Thanks for the pointer. The above issue was indeed occurring in my code.
For the benefit of all my fellow nodejs developers, what finally worked is the value of id_str of the original tweet had to be converted into string and then assigned it to parameter in_reply_to_status_id.