Tumblr API v1 hacking
by Chris Vitalos
HTML
<!DOCHTML>
<html>
<head>
<script>
function f(data) {
if (!data) {
console.log("json data block is empty!");
return;
}
var limit=+limit||5;
var response = data.posts;
var block = document.getElementById('FeaturedPost');
var post;
var len = Math.min(response.length, limit);
var embedApiHref = "https://embed.tumblr.com/embed/post/LUac6L4yNZqXpt0LGidojg/";
var recent;
var html;
for (var i = 0; i < len; ++i) {
post = response[i];
dataHref = embedApiHref + post['id'];
recent = document.createElement('div');
recent.setAttribute("class", "tumblr-post");
recent.setAttribute("data-href", dataHref);
html = "<li><a href='" +
(post['url-with-slug'] || post.url) + "'>" +
(post['url-with-slug'] || post.url) + "</a>";
recent.innerHTML = html;
block.appendChild(recent);
}
};
</script>
</head>
<body>
<div id="FeaturedPost"></div>
<div id="TumblrPosts"></div>
<script
src="https://washborodems.tumblr.com/api/read/json?callback=f&num=1&tagged=featured">
</script>
<script async src="https://assets.tumblr.com/post.js"></script>
</body>
</html>