我正在使用flickrapi进行NodeJS并继续遇到标题中列出的错误。
我的本地计算机(OSX 10.10.1)上的一切正常,但Azure每次都会窒息。该应用程序运行,但任何使用flickrapi扼流圈的东西。示例如下:
var express = require('express');
var router = express.Router();
var Flickr = require("flickrapi"),
flickrOptions = {
api_key: '**********',
secret: '***********'
};
router.get('/galleries', function(req, res) {
Flickr.tokenOnly(flickrOptions, function(error, flickr) {
var albums = [];
flickr.photosets.getList({ user_id: '*********' }, function(err, result) {
result.photosets.photoset.forEach(function(set){
albums.push(new Album(set));
});
albums.forEach(function(album, index, array) {
flickr.photosets.getPhotos({ photoset_id: album.id }, function(err, pResult) {
addPhotosToAlbum(pResult.photoset.photo, album, function() {
if (index === array.length - 1) {
res.json({ albums: albums });
}
});
});
})
});
});
});
function Album(photoset) {
this.id = photoset.id;
this.title = photoset.title._content;
this.photos = [];
}
function Photo(photo) {
this.url = new URL(photo);
}
function URL(photo) {
var url = 'http://farm' + photo.farm + '.static.flickr.com/' + photo.server + '/';
url += photo.id + '_' + photo.secret + '_';
this.thumbnail = url + 't.jpg';
this.small = url + 'm.jpg';
this.medium = url + 'z.jpg';
this.large = url + 'k.jpg';
}
function addPhotosToAlbum(photos, album, finish) {
photos.forEach(function(photo, index, array) {
album.photos.push(new Photo(photo));
if (index === array.length - 1) {
finish();
}
});
}
module.exports = router;
我删除了除初始查询之外的所有内容,即使是抛出错误:
router.get('/galleries', function(req, res) {
Flickr.tokenOnly(flickrOptions, function(error, flickr) {
flickr.photosets.getList({ user_id: '*********' }, function(err, result) {
res.json({ albums: result });
});
});
});