Twitter user timeline
Twitter user timeline
by Juan Muñoz
HTML
<script type="text/javascript">
TwitterAPI = {
Statuses: {
user_timeline:function(screen_name, count, callback){
jQuery.getJSON("http://twitter.com/statuses/user_timeline/" + screen_name + ".json?count="+count+"&b="+Math.random()+"&callback=?",
callback);
}
}
};
// @rem
window.ify=function(){var entities={'"':'"e;','&':'&','<':'<','>':'>'};return{"link":function(t){return t.replace(/[a-z]+:\/\/[a-z0-9-_]+\.[a-z0-9-_:~%&\?\/.=]+[^:\.,\)\s*$]/ig,function(m){return'<a href="'+m+'">'+((m.length>25)?m.substr(0,24)+'...':m)+'</a>';});},"at":function(t){return t.replace(/(^|[^\w]+)\@([a-zA-Z0-9_]{1,15})/g,function(m,m1,m2){return m1+'@<a href="http://twitter.com/'+m2+'">'+m2+'</a>';});},"hash":function(t){return t.replace(/(^|[^\w'"]+)\#([a-zA-Z0-9_]+)/g,function(m,m1,m2){return m1+'#<a href="http://search.twitter.com/search?q=%23'+m2+'">'+m2+'</a>';});},"clean":function(tweet){return this.hash(this.at(this.link(tweet)));}};}();
</script>
<div id="tweet"><h3>My Tweets</h3></div >
<script type="text/javascript">
jQuery(document).ready(function($){
TwitterAPI.Statuses.user_timeline("TpgSpA",10,function(json){
content = '<ul>';
$.each(json, function(i){
var tweet = ify.clean(this['text']);
var d = new Date(this['created_at']);
var date_show = d.getDate()+'/'+d.getMonth()+'/'+d.getFullYear()+' '+d.getHours()+':'+d.getMinutes();
content += '<li>' + tweet + ' (<date>'+date_show+'</date>)</li>';
});
content += '</ul>';
$('#tweet').append(content);
});
});
</script>