From 320ebdbc1f4d534314270d20af51d773b7ec8a13 Mon Sep 17 00:00:00 2001 From: Cristian Necula Date: Sat, 1 Oct 2016 08:16:05 +0300 Subject: [PATCH 1/2] (feat) add user_self method Add method for retrieving user info based on the used access token --- lib/instagram.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/lib/instagram.js b/lib/instagram.js index 77cdba1..d8e070b 100644 --- a/lib/instagram.js +++ b/lib/instagram.js @@ -372,6 +372,27 @@ var instagram = function(spec, my) { }, retry); }; + /** + * Retrieves information about the given user + * @param id string the user id + * @param cb function (err, user, remaining, limit); + */ + user_self = function(cb) { + var retry = function() { + user(cb); + }; + + call('GET', '/users/self', {}, function(err, result, remaining, limit) { + if(err) { + return handle_error(err, cb, retry); + } else if(result && result.meta && result.meta.code === 200) { + return cb(null, result.data, remaining, limit); + } else { + return handle_error(result, cb, retry); + } + }, retry); + }; + /** * Retrieves the current user feed * @param options object { count, [opt] @@ -1741,6 +1762,7 @@ var instagram = function(spec, my) { fwk.method(that, 'use', use, _super); fwk.method(that, 'user', user, _super); + fwk.method(that, 'user_self', user_self, _super); fwk.method(that, 'user_self_feed', user_self_feed, _super); fwk.method(that, 'user_media_recent', user_media_recent, _super); fwk.method(that, 'user_self_media_recent', user_self_media_recent, _super); From d9ed658110fdcb6e993f50b6812caff49b60b21b Mon Sep 17 00:00:00 2001 From: Cristian Necula Date: Thu, 17 Nov 2016 19:41:40 +0200 Subject: [PATCH 2/2] (fix) user_self missing declaration --- lib/instagram.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/instagram.js b/lib/instagram.js index d8e070b..5ba0d97 100644 --- a/lib/instagram.js +++ b/lib/instagram.js @@ -49,6 +49,7 @@ var instagram = function(spec, my) { var use; /* use(spec); */ var user; /* user(user_id, cb); */ + var user_self; /* user_self(cb); */ var user_self_feed; /* user_self_feed(options, cb); */ var user_media_recent; /* user_media_recent(user_id, options, cb); */ var user_self_media_recent; /* user_self_media_recent(options, cb); */ @@ -374,7 +375,6 @@ var instagram = function(spec, my) { /** * Retrieves information about the given user - * @param id string the user id * @param cb function (err, user, remaining, limit); */ user_self = function(cb) {