How can I get and then display a random image from a post from a specific tumblr with javascript?
I want it to be simple, something like when a button is pushed display a the random image.
I'm just going to use foodgif.tumblr.com as an example. So far I know you can get a random post just by including /random onto the end of the url. (so http://foodgif.tumblr.com/random will grab a random url that could be used to grab the image from)
I also found tumblrbot, which is a Hubot-compatible Tumblr API wrapper for Node.js, and has code like the following:
tumblr = require('tumblrbot')
tumblr.photo("foodgif.tumblr.com").random (post) ->
console.log post.photos[0].original_size.url
but all their code/examples seems to be in coffee script, and I'm already new to html/javascript/jquery. Is there code usable in normal javascript?
I could also just use the actual tumblr API, but other methods seems simpler and promising, so I'd rather that be a last resort. Anyway I feel like I've got the means capable to do it, I just don't really know exactly how. Any help?
I wrote example that get photos from foodgif blog via JS. Link is below.
Tumblr API - Get Photos via JS (JS Bin)
If you want to use this code, you must change api key.