Last active
August 29, 2015 14:05
-
-
Save flipjs/ff0b605b4f67891e8c34 to your computer and use it in GitHub Desktop.
Google+ Photos API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env node | |
| var http = require('http') | |
| // Google Plus Photos API | |
| // Sample data from Felipe Apostol's Street Photography album | |
| // userId is 102873175118305865375 | |
| // albumId is 5646665615382099025 | |
| var options = { | |
| host: 'picasaweb.google.com', | |
| path: '/data/feed/api/user/102873175118305865375/' | |
| + 'albumid/5646665615382099025' | |
| + '?alt=json' | |
| } | |
| var req = http.request(options, function(res) { | |
| var body = '' | |
| res.setEncoding('utf8') | |
| res.on('readable', function() { | |
| var chunk = this.read() || '' | |
| body += chunk | |
| }) | |
| res.on('end', function() { | |
| var gplus = JSON.parse(body) | |
| var len = gplus.feed.entry.length | |
| ;(function iterator(i) { | |
| if (i >= len) return | |
| // we are interested with feed.entry property | |
| // log photo url + caption | |
| console.log('' + (i+1) + '. ' | |
| + gplus.feed.entry[i].content.src | |
| + ' - ' + gplus.feed.entry[i].summary['$t']) | |
| iterator(i + 1) | |
| })(0) | |
| }) | |
| req.on('error', function(e) { | |
| console.log('error' + e.message) | |
| }) | |
| }) | |
| req.end() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment