Skip to content

Instantly share code, notes, and snippets.

@t-kashima
Created January 15, 2012 17:10
Show Gist options
  • Save t-kashima/1616470 to your computer and use it in GitHub Desktop.
Save t-kashima/1616470 to your computer and use it in GitHub Desktop.
var express = require('express');
var request = require('request');
var querystring = require('querystring');
var app = express.createServer();
var baseurl = "http://api.flickr.com/services/rest";
var searchPhotoQuery = {
method: "flickr.photos.search",
api_key: "",
min_taken_date: "2011-01-13 00:00:00",
max_taken_date: "2011-01-16 01:00:00",
text: 'photo',
format: 'json',
nojsoncallback: 1
};
var photoInfoQuery = {
method: "flickr.photos.getInfo",
api_key: "",
format: 'json',
nojsoncallback: 1
};
function makeFlickrImageUrl(farmId, serverId, id, secret) {
return "http://farm" + farmId + ".staticflickr.com/" + serverId + "/" + id + "_" + secret + ".jpg";
}
function makeFlickrImage(photo) {
return makeFlickrImageUrl(photo.farm, photo.server, photo.id, photo.secret);
}
function getPhotoDate(id) {
photoInfoQuery.photo_id = id;
var url = baseurl + "?" + querystring.stringify(photoInfoQuery);
request({uri: url}, function(error, res, body) {
var json = JSON.parse(body);
console.log(json.photo.dates.taken);
});
}
function jsonFlickrApi(error, res, body) {
var json = JSON.parse(body);
var photos = json.photos.photo;
var photo = photos[0];
getPhotoDate(photo.id);
};
app.get('/', function(req, res) {
var url = baseurl + "?" + querystring.stringify(searchPhotoQuery);
request({uri: url}, jsonFlickrApi)
res.send('hello');
});
app.listen(8124);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment