-
Notifications
You must be signed in to change notification settings - Fork 0
/
api.js
33 lines (30 loc) · 953 Bytes
/
api.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/*jshint node:true,expr:true*/
'use strict';
var spashttp = require("spas-http");
var async = require("async");
exports.albumsWithPhotos = function(params, credentials, cb) {
var BASEURL = "https://picasaweb.google.com/data/feed/api/user/";
params.url = BASEURL + params.userid;
spashttp.request(params, credentials, function(err, result) {
if (!err) {
async.each(result.data.items, function(album, callback) {
var shadowed = JSON.parse(JSON.stringify(params));
shadowed.url = shadowed.url + "/albumid/" + album.id;
spashttp.request(shadowed, credentials, function(err, photos) {
if (photos.data && photos.data.items) {
album.photos = photos.data.items;
}
callback();
});
}, function(error) {
if (error) {
console.log(error);
} else {
cb(err,result);
}
});
} else {
cb(err, {});
}
});
};