foursquarevenues
Advanced tools
Comparing version 0.0.0 to 0.0.2
@@ -7,3 +7,3 @@ // Generated by CoffeeScript 1.3.3 | ||
foursquare = (require('./foursquarevenues'))("client_idKEY", "client_secretKEY"); | ||
foursquare = (require('./foursquarevenues'))("CLIENT_ID_KEY", "CLIENT_SECRET_KEY"); | ||
@@ -20,2 +20,8 @@ params = { | ||
foursquare.exploreVenues(params, function(error, venues) { | ||
if (!error) { | ||
return console.log(venues); | ||
} | ||
}); | ||
}).call(this); |
@@ -10,5 +10,16 @@ // Generated by CoffeeScript 1.3.3 | ||
module.exports = function(client_id, client_secret) { | ||
var date, day, month, today; | ||
today = new Date(); | ||
month = today.getMonth() + 1; | ||
if (month < 10) { | ||
month = "0" + month; | ||
} | ||
day = today.getDate(); | ||
if (day < 10) { | ||
day = "0" + day; | ||
} | ||
date = today.getFullYear() + month + day; | ||
return { | ||
getVenues: function(params, callback) { | ||
var date, day, month, today, urlString; | ||
var urlString; | ||
urlString = "https://api.foursquare.com/v2/venues/search?"; | ||
@@ -66,12 +77,69 @@ if (params.ll != null) { | ||
} | ||
today = new Date(); | ||
month = today.getMonth() + 1; | ||
if (month < 10) { | ||
month = "0" + month; | ||
urlString += "&v=" + date; | ||
return request(urlString, function(error, response, body) { | ||
if (!error && response.statusCode === 200) { | ||
callback(null, JSON.parse(body)); | ||
} | ||
if (response.statusCode === 400) { | ||
callback("400", null); | ||
} | ||
if (response.statusCode === 401) { | ||
callback("401", null); | ||
} | ||
if (response.statusCode === 403) { | ||
callback("403", null); | ||
} | ||
if (response.statusCode === 404) { | ||
callback("404", null); | ||
} | ||
if (response.statusCode === 405) { | ||
callback("405", null); | ||
} | ||
if (response.statusCode === 409) { | ||
callback("409", null); | ||
} | ||
if (response.statusCode === 500) { | ||
return callback("500", null); | ||
} | ||
}); | ||
}, | ||
exploreVenues: function(params, callback) { | ||
var urlString; | ||
urlString = "https://api.foursquare.com/v2/venues/explore?"; | ||
if (params.ll != null) { | ||
urlString += "&ll=" + params.ll; | ||
} | ||
day = today.getDate(); | ||
if (day < 10) { | ||
day = "0" + day; | ||
if (params.near != null) { | ||
urlString += "&near=" + params.near; | ||
} | ||
date = today.getFullYear() + month + day; | ||
if (params.llAcc != null) { | ||
urlString += "&llAcc=" + params.llAcc; | ||
} | ||
if (params.alt != null) { | ||
urlString += "&alt=" + params.alt; | ||
} | ||
if (params.altAcc != null) { | ||
urlString += "&altAcc=" + params.altAcc; | ||
} | ||
if (params.query != null) { | ||
urlString += "&ll=query" + params.query; | ||
} | ||
if (params.limit != null) { | ||
urlString += "&limit=" + params.limit; | ||
} | ||
if (params.section != null) { | ||
urlString += "§ion=" + params.section; | ||
} | ||
if (params.radius != null) { | ||
urlString += "&radius=" + params.radius; | ||
} | ||
if (params.novelty != null) { | ||
urlString += "&novelty=" + params.novelty; | ||
} | ||
if (client_id != null) { | ||
urlString += "&client_id=" + client_id; | ||
} | ||
if (client_secret != null) { | ||
urlString += "&client_secret=" + client_secret; | ||
} | ||
urlString += "&v=" + date; | ||
@@ -78,0 +146,0 @@ return request(urlString, function(error, response, body) { |
{ | ||
"name": "foursquarevenues", | ||
"version": "0.0.0", | ||
"version": "0.0.2", | ||
"description": "Simple query to 4square venue's api", | ||
@@ -15,3 +15,5 @@ "main": "./foursquarevenues", | ||
"foursquare", | ||
"node" | ||
"venues", | ||
"search", | ||
"explore" | ||
], | ||
@@ -18,0 +20,0 @@ "author": "Yamil Asusta (elbuo8)", |
@@ -1,4 +0,31 @@ | ||
4square | ||
======= | ||
# Foursquare Venues API | ||
This is a simple module to access 4squares' venue API. | ||
Fast access to 4square venues using node | ||
npm install foursquarevenues | ||
## Example | ||
```js | ||
var foursquare = (require('./foursquarevenues'))("CLIENTIDKEY", "CLIENTSECRETKEY"); | ||
var params = { | ||
"ll": "40.7,-74" | ||
}; | ||
foursquare.getVenues(params, function(error, venues) { | ||
if (!error) { | ||
console.log(venues); | ||
} | ||
}); | ||
foursquare.exploreVenues(params, function(error, venues) { | ||
if (!error) { | ||
console.log(venues); | ||
} | ||
}); | ||
``` | ||
**Enjoy the usage. You can email me at yamil.asusta@upr.edu for any bugs.** | ||
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
11027
189
32