Skip to content

Instantly share code, notes, and snippets.

@choonkeat
Created August 4, 2009 22:32
Show Gist options
  • Save choonkeat/162360 to your computer and use it in GitHub Desktop.
Save choonkeat/162360 to your computer and use it in GitHub Desktop.
Just edit the 2 parameters on line 11 -- search term, and css selector
<html><body>
<script src="http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js"></script>
<script>
(function(search_term, css_selector) {
jQuery.getJSON("http://search.twitter.com/search.json?q=" + encodeURIComponent(search_term) + "&callback=?", function(json) {
var tweet_html = [];
jQuery.each(json.results, function(index, tweet) {
tweet_html.push("<li><img style='height: 48px;' src='" + tweet.profile_image_url + "'/>\n<span class='author'>" + tweet.from_user + "</span>\n<span class='tweet'>" + tweet.text + "</span></li>");
});
jQuery(document.body).append("<ol>" + tweet_html.join("") + "</ol>");
});
})("nba", "html > body");
</script>
</body></html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment