Skip to content

Instantly share code, notes, and snippets.

@alexanderk23
Last active December 15, 2015 05:29
Show Gist options
  • Select an option

  • Save alexanderk23/5209578 to your computer and use it in GitHub Desktop.

Select an option

Save alexanderk23/5209578 to your computer and use it in GitHub Desktop.
Pure JS solution
<html>
<head>
<script src="https://raw.github.com/remy/twitterlib/master/twitterlib.min.js"></script>
<script src="https://raw.github.com/timrwood/moment/2.0.0/min/moment.min.js"></script>
</head>
<body>
<div id="tweet" data-username="bountify"></div>
<script>
var tweet = document.getElementById('tweet');
var username = tweet.getAttribute('data-username');
twitterlib.timeline(username, { limit: 3 }, function(tweets) {
for(var i = 0; i < tweets.length; i++) {
var newItem = document.createElement("DIV");
var ts = moment(tweets[i].created_at).fromNow();
newItem.innerHTML = this.ify.clean(tweets[i].text) + ' <small>(' + ts + ')</small>';
tweet.appendChild(newItem);
}
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment