Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Add parameter to users.id #8

Open
wants to merge 3 commits into from

2 participants

@j6s

This is helpfull, when trying to get information about private users, that you have in your friendlist

gate8team and others added some commits
@j6s

Looks like the the pullrequest #7 from @gate8team slipped in here somehow. The only commit this PR should contain is 0282bb8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 7, 2014
  1. @gate8team
Commits on Jun 14, 2014
  1. @j6s

    Add parameter to users.id

    j6s authored
    This is helpfull, when trying to get information about private users, that you have in your friendlist
  2. @j6s
This page is out of date. Refresh to see the latest.
Showing with 27 additions and 16 deletions.
  1. +27 −16 index.js
View
43 index.js
@@ -33,20 +33,24 @@ InstagramClient.prototype.fetch = function (path, params, callback) {
raw += chunk;
});
res.on('end', function () {
- var response = JSON.parse(raw);
-
- var pagination = null;
- if (typeof(response['pagination']) != 'undefined') {
- pagination = response['pagination'];
- }
-
- if (response['meta']['code'] == 200) {
- callback(response['data'],
- null,
- pagination);
- }else{
- callback(response['meta'], response['meta']['code'], pagination);
- }
+ try{
+ var response = JSON.parse(raw);
+
+ var pagination = null;
+ if (typeof(response['pagination']) != 'undefined') {
+ pagination = response['pagination'];
+ }
+
+ if (response['meta']['code'] == 200) {
+ callback(response['data'],
+ null,
+ pagination);
+ }else{
+ callback(response['meta'], response['meta']['code'], pagination);
+ }
+ } catch (e) {
+ callback({}, {}, {});
+ }
});
});
}
@@ -119,8 +123,15 @@ function InstagramUsersClient (parent) {
this.parent = parent;
}
-InstagramUsersClient.prototype.id = function (id, callback) {
- this.parent.fetch('/v1/users/'+id, callback);
+InstagramUsersClient.prototype.id = function (id, params, callback) {
+ if (typeof params == "function") {
+ // be compatible with old implementations, where the second parameter was the callback
+ callback = params;
+ this.parent.fetch('/v1/users/' + id, callback);
+
+ } else {
+ this.parent.fetch('/v1/users/' + id, params, callback);
+ }
}
InstagramUsersClient.prototype.media = function (id, params, callback) {
Something went wrong with that request. Please try again.