Skip to content

Instantly share code, notes, and snippets.

@flipjs
Last active August 29, 2015 14:05
Show Gist options
  • Select an option

  • Save flipjs/ff0b605b4f67891e8c34 to your computer and use it in GitHub Desktop.

Select an option

Save flipjs/ff0b605b4f67891e8c34 to your computer and use it in GitHub Desktop.
Google+ Photos API
#!/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