Skip to content

Instantly share code, notes, and snippets.

@thebigbad
Created August 6, 2013 21:32
Show Gist options
  • Save thebigbad/6168884 to your computer and use it in GitHub Desktop.
Save thebigbad/6168884 to your computer and use it in GitHub Desktop.
// http://simonenko.su/8169320732/node-tumblr-my-first-nodejs-module
var Tumblr = require('tumblr').Tumblr,
fs = require('fs');
var blog = new Tumblr(
'YOURTUMBLELOG.tumblr.com',
'YOURAPIKEY');
var get = function(offset) {
offset = offset || 0;
var options = {
offset: offset
};
blog.posts(options, function(err, res) {
if (err) {
throw new Error(err);
}
if (res.posts.length == 0) {
return;
}
res.posts.forEach(function(post) {
var path = [process.cwd(), 'input', 'bands', post.id + '.json'].
join('/');
fs.writeFileSync(path, JSON.stringify(post));
});
get(offset + 20);
});
};
get();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment