Permalink
Browse files

Merge pull request #13 from jonmarkgo/master

Fixed errors in example and added addCheckin
  • Loading branch information...
clintandrewhall committed Jan 7, 2013
2 parents f15981c + 64934cb commit 18689aeebb7c9594f6929c952db2ad529e30f87e
Showing with 29 additions and 3 deletions.
  1. +26 −0 lib/checkins.js
  2. +3 −3 readme.md
View
@@ -30,6 +30,31 @@ module.exports = function(config) {
core.callApi(path.join('/checkins', checkinId), accessToken, params || {}, callback);
}
+ /**
+ * Add a Foursquare Check-in.
+ * @memberof module:node-foursquare/Checkins
+ * @param {String} venueId The id of the venue to check-in to.
+ * @param {Object} [params] An object containing additional parameters. Refer to Foursquare documentation for details
+ * on currently supported parameters.
+ * @param {String} accessToken The access token provided by Foursquare for the current user.
+ * @param {Function} callback The function to call with results, function({Error} error, {Object} results).
+ * @see https://developer.foursquare.com/docs/checkins/add
+ */
+ function addCheckin(venueId, params, accessToken, callback) {
+ logger.enter('addCheckin');
+
+ if(!venueId) {
+ logger.error('addCheckin: venueId is required.');
+ callback(new Error('Checkins.addCheckin: venueId is required.'));
+ return;
+ }
+
+ params = params || {};
+ params.venueId = venueId;
+
+ core.callApi('/checkins/add', accessToken, params, callback, 'POST');
+ }
+
/**
* Retrieve the 'likes' for a Foursquare Check-in.
* @memberof module:node-foursquare/Checkins
@@ -127,6 +152,7 @@ module.exports = function(config) {
return {
'addCommentToCheckin': addCommentToCheckin,
'deleteCommentFromCheckin': deleteCommentFromCheckin,
+ 'addCheckin' : addCheckin,
'getCheckin' : getCheckin,
'getLikes' : getLikes,
'getRecentCheckins' : getRecentCheckins
View
@@ -48,16 +48,16 @@ Foursquare URLs if necessary, (but that is unlikely).
Once instantiated, you just need to set up endpoints on your own server that match your OAuth configuration
in Foursquare. Using Express, for example:
- var app = express.createServer();
+ var app = express();
app.get('/login', function(req, res) {
- res.writeHead(303, { 'location': Foursquare.getAuthClientRedirectUrl() });
+ res.writeHead(303, { 'location': foursquare.getAuthClientRedirectUrl() });
res.end();
});
app.get('/callback', function (req, res) {
- Foursquare.getAccessToken({
+ foursquare.getAccessToken({
code: req.query.code
}, function (error, accessToken) {
if(error) {

0 comments on commit 18689ae

Please sign in to comment.