Tumblr API V2
by bluetidepro
HTML
<ul id="posts">
<li><h2>POSTS!</h2><hr/></li>
</ul>
<a href="#" id="json_click_handler">Load . . .</a>
<div id="sound"></div>
<!-- http://www.tumblr.com/docs/en/api/v2#posts //-http://jsonviewer.stack.hu/ // http://api.tumblr.com/v2/blog/blog.iamzachreed.com/posts/quote/?api_key=dqtYbaUpm3nHu5kKJDCA2eywPrwqSgP2CfnHAuboBC55JlhQQD&limit=2&offset=0 ->
CSS
body{padding:20px;}h2{font-weight:bold;}
JavaScript
$(document).ready(function() {
i = 0;
doAjaxRequest(i);
$('#json_click_handler').on('click', function(event) {
event.preventDefault();
i = i + 10;
doAjaxRequest(i);
});
function doAjaxRequest(i) {
$.ajax({
type: "GET",
url: "http://api.tumblr.com/v2/blog/blog.iamzachreed.com/posts/quote/",
dataType: "jsonp",
data: {
api_key: "dqtYbaUpm3nHu5kKJDCA2eywPrwqSgP2CfnHAuboBC55JlhQQD",
limit: "10",
offset: i,
jsonp: "jsonCallback"
}
});
jsonCallback = function(json) {
if (json.response.posts != '') {
$.each(json.response.posts, function(index, item) {
var quote_id = item["text"];
// alert(quote_id);
$('#posts').append('<li>' + quote_id + '<hr/></li>');
});
//alert(i);
} else {
alert('NO MORE POSTS TO LOAD!');
document.getElementById("sound").innerHTML = "<embed src='http://dcc.ndhu.edu.tw/monbaza/soundbook/sound/dog_bark_front.mp3' hidden=true autostart=true loop=false>";
};
};
};
});
/*
var entry = json.response.posts[Math.floor(Math.random() * json.response.posts.length)];
var entry = json.response.posts[0];
var quote_id = entry["id"];
var quote_url = entry["post_url"];
var quote_content = entry["text"];
var quote_source = entry["source"];
var quote_notes = entry["note_count"];
$('#posts').append('<li><div id="post-' + quote_id + '" class="postWrap type-quote"><div class="twelve columns post"><div class="post-title"><h2 class="title"><span class="symbol quote"><a href="' + quote_url + '" title="Design Quote">Design Quote</a></h2></div><blockquote><strong>“</strong>' + quote_content +...