Skip to content

Instantly share code, notes, and snippets.

@DracoBlue
Last active March 28, 2024 12:44
Show Gist options
  • Save DracoBlue/488466eaabbb674c636f to your computer and use it in GitHub Desktop.
Save DracoBlue/488466eaabbb674c636f to your computer and use it in GitHub Desktop.
Poor mans twitter to twtxt converter
var Twitter = require("twitter");
var moment = require("moment");
var client = new Twitter({
consumer_key: 'XXX', /* copy from https://apps.twitter.com/app/APPID/keys */
consumer_secret: 'XXX2', /* copy from https://apps.twitter.com/app/APPID/keys */
access_token_key: '',
access_token_secret: ''
});
var params = {screen_name: 'YOURUSERNAME'}; /* e.g. dracoblue */
client.get('statuses/user_timeline', params, function(error, tweets, response){
if (!error) {
tweets.forEach(function(tweet) {
console.log(moment(new Date(Date.parse(tweet.created_at.replace(/( \+)/, ' UTC$1')))).format('YYYY-MM-DDTHH:mm:ss.SSSZ') + "\t" + tweet.text.replace(/[\n\r]/g, " "));
});
}
});
2016-02-06T11:48:23.000+01:00 RT @hackernewsbot: Show HN: Twtxt – Decentralised, minimalist microblogging service for hackers... https://t.co/QetAUkvYZI
2016-02-06T08:56:26.000+01:00 RT @Real_CSS_Tricks: This is _good_ advice for making good slides of any kind: https://t.co/DcWwJIA1Zb by @ilikevests
2016-01-31T23:14:55.000+01:00 "Local Elasticsearch Cluster Status = RED" https://t.co/WZumSoKQwj
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment