Skip to content

Instantly share code, notes, and snippets.

@oivoodoo
Created March 21, 2011 10:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oivoodoo/879261 to your computer and use it in GitHub Desktop.
Save oivoodoo/879261 to your computer and use it in GitHub Desktop.
Retrieve data from twitter and tumblr for my own web site.
$(function(){
$.getJSON('http://search.twitter.com/search.json?callback=?&q=oivoodoo&rpp=5', function(data){
var html = "";
for(var i = 0; i < data.results.length; i++) {
var tweet = data.results[i];
html += "<div class='tweet'><a href='http://twitter.com/oivoodoo/'>@oivoodoo</a>:<span>" + tweet.text + '</span></div>';
}
$('#twitter').html(html);
});
$.getJSON('http://oivoodoo.tumblr.com/api/read/json?callback=?', function(data){
var html = "";
var MAX = 5;
for(var i = 0; (i < MAX) && data.posts.length > i; i++) {
var post = data.posts[i];
if (!!post['regular-title']) {
html += "<div class='post'><a href='" + post.url + "'>" + post['regular-title'] + "</a><p>";
if (!!post.tags) {
for(var j = 0; j < post.tags.length; j++) {
html += "<a class='contact' href='http://oivoodoo.tumblr.com/tagged/" + post.tags[j] + "/chrono'>" + post.tags[j] + "</a>";
}
}
} else {
MAX += 1;
}
}
$('#tumblr').html(html);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment