Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Basic tweet parsing via json and jquery
<script>
$(document).ready(function(){
//Tell the function where the feed is located
$.getJSON("https://api.twitter.com/1/statuses/user_timeline.json?screen_name=tw2113&trim_user=1&count=5&include_rts=1&callback=?", function(data){
//Grab each of the "entries"
$.each(data, function(i,item){
//Create the links and throw them
//into the body of the page
function twitify( text ) {
// replace urls with linked ones
var t2 = text.replace(/(http|https)(:\/\/)([^ )]+)/ig, '<a href="$1$2$3">$1$2$3</a>' );
// replace @username with clickable twitter link
t2 = t2.replace(/@([^ ]+)/gi,'<a href="http://twitter.com/$1">@$1</a>');
// replace hashtags with Twitter searches
t2 = t2.replace(/#([^ ]+)/gi,'<a href="http://search.twitter.com/search?q=%23$1">#$1</a>');
return t2;
}
$("#tweets").append("<p>"+twitify(item.text)+"</p>");
});
});
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.