Created
February 21, 2010 20:48
-
-
Save mrandyclark/310530 to your computer and use it in GitHub Desktop.
Grabs a JSON version of your twitter feed and displays it.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" | |
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | |
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> | |
<title>Tweets</title> | |
<script type="text/javascript" language="javascript" src="jquery-1.4.1.min.js"></script> | |
<script> | |
$(document).ready(function(){ | |
// your username | |
var username = "mrandyclark" | |
// number of tweets to grab | |
var numOfTweets = "1" | |
var twitter_url = "http://twitter.com/status/user_timeline/" + username +".json?count=" + numOfTweets + "&callback=?"; | |
$.getJSON(twitter_url, function(data){ | |
$.each(data, function(i, item) { | |
$("#latest_tweets").append( | |
linkify(item.text) | |
) | |
}); | |
}); | |
}); | |
// changes links in your tweet to html links | |
function linkify(text) { | |
var exp = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig; | |
return text.replace(exp,"<a href='$1' target=\"_blank\">$1</a>"); | |
}; | |
</script> | |
</head> | |
<body> | |
<div id="latest_tweets"></div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment