node-twitter
node-twitter copied to clipboard
Tweet ID get rounded
I want to save the ID of a tweet but I will receive something like this
1026837156479718000
instead of
1026837156479717985
Is there a way to disable the rounded numbers?
@Fchen48 it's not because of the library, it's because Javascript cannot support numbers with > 53-bits, see: https://developer.twitter.com/en/docs/basics/twitter-ids
But the library, knowing that this is a limitation, could work around it. The easiest way would be to preprocess the JSON string for ids.json to make them all strings before parsing them. I'm sure there is a more elegant way, but that is a workaround.
After further inspecting the API, there is an option you can add for the ids.json request to "stringify ids"
Name | Required | Description | Default Value | Example |
---|---|---|---|---|
stringify_ids | optional | Some programming environments will not consume Twitter IDs due to their size. Provide this option to have IDs returned as strings instead. More about Twitter IDs. | false | true |
You can pass this as a parameter for the client:
client.get("followers/ids", { screen_name:"twitterdev", "stringify_ids":true }, callback)
hello, I don't know if I should be posting here but I need help regarding a twitter bot which I am trying to make (which will reply to a particular phrase or hashtag) but something is wrong. I will appreciate if anyone can help solve it. here is the code
console.log('the bot is starting');
var Twit = require ('twit');
var config = require('./config'); var T = new Twit(config);
var query = "alot"; T.get('search/tweets', { q: query, count: 1, lang: "en" }, function (error, tweets, response) { var tweetList = tweets['statuses'];
for (var i = 0; i < tweetList.length; i++) {
var id = { id: tweetList[i].id_str }
if ('retweeted_status' in tweetList[i])
continue;
}
var message = "Alot confused, a lot not understand feelings";
var tweetId = tweetList[i].id_str
try {
T.post('statuses/update',
{ "status": message, "in_reply_to_status_id": tweetId },
function (error, tweets, response) {
console.log("Tweet posted successfully!")
});
}
catch (err) {
console.log(err);
}
});
See https://github.com/draftbit/twitter-lite#numeric-vs-string-ids