Skip to content

Instantly share code, notes, and snippets.

@pokle
Created September 20, 2012 06:19
Show Gist options
  • Save pokle/3754241 to your computer and use it in GitHub Desktop.
Save pokle/3754241 to your computer and use it in GitHub Desktop.
How to display your tweets without a plugin
<!DOCTYPE html>
<html>
<head>
<title>Just the latest tweet</title>
</head>
<body>
<script>
// From http://twitter.com/javascripts/blogger.js
function tweettweet(twitters) {
var statusHTML = [];
for (var i = 0; i < twitters.length; i++) {
var username = twitters[i].user.screen_name;
var status = twitters[i].text.replace(/((https?|s?ftp|ssh)\:\/\/[^"\s\<\>]*[^.,;'">\:\s\<\>\)\]\!])/g, function(url) {
return '<a href="' + url + '">' + url + '</a>';
}).replace(/\B@([_a-z0-9]+)/ig, function(reply) {
return reply.charAt(0) + '<a href="http://twitter.com/' + reply.substring(1) + '">' + reply.substring(1) + '</a>';
});
statusHTML.push('<li><span>' + status + '</span> <a style="font-size:85%" href="http://twitter.com/' + username + '/statuses/' + twitters[i].id_str + '">' + (twitters[i].created_at) + '</a></li>');
}
document.getElementById('twitter_update_list').innerHTML = statusHTML.join('');
}
</script>
<div id="twitter_update_list"></div>
<script type="text/javascript" src="//twitter.com/statuses/user_timeline/tusharpokle.json?callback=tweettweet&count=1"></script>
</body>
</html>
@pokle
Copy link
Author

pokle commented Sep 20, 2012

Oh, and replace 'tusharpokle' with your own twitter id.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment