Tumblr API SSL?

14. January 2013. Tagged tricks, website, apache, tumblr, ssl.

Well, as I have been rebuilding my website recently, I wanted to separated my personal representation (here: my website) and my blog. Still, my blog is a representation of me, and so I decided that I want to have some of my posts on my website. As it is a static html file though and I did not want to update it every time I write a blog post (if I wanted to do that, I would not have used tumblr..) I decided to go for javscript.

Tumblr has a simple API to access your posts and with this little script I added them to my website:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
if (tumblr_api_read) {
			html = '<ul class="unstyled">';
			for (i=0; i < 15; i++) {
				post = tumblr_api_read.posts[i];
				if (post) {
					li = '<li><a href="' + post['url-with-slug'] + '">' + post['regular-title'] +'</a> <small>' + post['date'] + '</small></li>';
					html += li;
				}
				else {
					break;
				}
			};
			html += '</ul>';
			$('#tumblr-posts').append(html);
		};
	});

You just have to include your personal tumblr js file before that, wich generally has the url http://<tumblrname>.tumblr.com/api/read/json. That file will set the tumblr_api_read that is iterated over here.

Unfortunately the API does not allow ssl-encrypted access and thus Chrome blocks the request on https:// sites and nobody can see my post.

So I wondered what I could do about that, and came up with the following hack:

1
RewriteRule ^tumblr/api/read/json$ http://blog.julo.ch/api/read/json [P]

I added this file to my .htaccess, which will internally proxy the request. On my page I just add /tumblr/api/read/json and everything is alright. I know that this kind of defeats the purpose of the ssl-thing, but yeah, I do not really have a chance here.

If anyone has a better idea, please let me know!