node-ainzfb-new 1.6.2702-test → 1.6.2729-test
Sign up to get free protection for your applications and to get access to all the features.
- package/package.json +1 -1
- package/src/getUserID.js +12 -16
package/package.json
CHANGED
package/src/getUserID.js
CHANGED
@@ -17,21 +17,19 @@ function formatData(data) {
|
|
17
17
|
};
|
18
18
|
}
|
19
19
|
|
20
|
-
module.exports = function(defaultFuncs, api, ctx) {
|
20
|
+
module.exports = function (defaultFuncs, api, ctx) {
|
21
21
|
return function getUserID(name, callback) {
|
22
|
-
var resolveFunc = function(){};
|
23
|
-
var rejectFunc = function(){};
|
22
|
+
var resolveFunc = function () { };
|
23
|
+
var rejectFunc = function () { };
|
24
24
|
var returnPromise = new Promise(function (resolve, reject) {
|
25
25
|
resolveFunc = resolve;
|
26
26
|
rejectFunc = reject;
|
27
27
|
});
|
28
28
|
|
29
29
|
if (!callback) {
|
30
|
-
callback = function (err,
|
31
|
-
if (err)
|
32
|
-
|
33
|
-
}
|
34
|
-
resolveFunc(friendList);
|
30
|
+
callback = function (err, data) {
|
31
|
+
if (err) return rejectFunc(err);
|
32
|
+
resolveFunc(data);
|
35
33
|
};
|
36
34
|
}
|
37
35
|
|
@@ -43,24 +41,22 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
43
41
|
path: "/home.php",
|
44
42
|
request_id: utils.getGUID()
|
45
43
|
};
|
46
|
-
|
44
|
+
var { getAccessToken } = require('../Extra/ExtraAddons');
|
47
45
|
defaultFuncs
|
48
46
|
.get("https://www.facebook.com/ajax/typeahead/search.php", ctx.jar, form)
|
49
|
-
.then(
|
50
|
-
.then(function(resData) {
|
51
|
-
if (resData.error)
|
52
|
-
throw resData;
|
53
|
-
}
|
47
|
+
.then(getAccessToken(ctx, defaultFuncs))
|
48
|
+
.then(function (resData) {
|
49
|
+
if (resData.error) throw resData;
|
54
50
|
|
55
51
|
var data = resData.payload.entries;
|
56
52
|
|
57
53
|
callback(null, data.map(formatData));
|
58
54
|
})
|
59
|
-
.catch(function(err) {
|
55
|
+
.catch(function (err) {
|
60
56
|
log.error("getUserID", err);
|
61
57
|
return callback(err);
|
62
58
|
});
|
63
59
|
|
64
60
|
return returnPromise;
|
65
61
|
};
|
66
|
-
};
|
62
|
+
};
|