Skip to content

Instantly share code, notes, and snippets.

@n9ti
Created August 31, 2014 18:45
Show Gist options
  • Save n9ti/826ad6ffb55a5dc21e61 to your computer and use it in GitHub Desktop.
Save n9ti/826ad6ffb55a5dc21e61 to your computer and use it in GitHub Desktop.
Simple Facebook Page Photos Downloader
var https = require('https');
var fs = require('fs');
https.get("https://graph.facebook.com/204379732996457/photos", function(response) {
var result = '';
response.on('data', function (chunk) {
result += chunk;
});
response.on('end', function (chunk) {
var photos = JSON.parse(result);
for(var i=0;i<photos.data.length;i++) {
var photo = photos.data[i];
console.log(photo.id);
downloadImage(photo.id, photo.source);
}
});
});
function downloadImage(id, url) {
var file = fs.createWriteStream(id + '.jpg');
var request = https.get(url, function(response) {
response.pipe(file);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment