-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathuser-service.js
34 lines (27 loc) · 849 Bytes
/
user-service.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
'use strict';
const request = require('request');
const config = require('./config');
const pg = require('pg');
pg.defaults.ssl = true;
module.exports = {
addUser: function(callback, userId) {
request({
uri: 'https://graph.facebook.com/v3.2/' + userId,
qs: {
access_token: config.FB_PAGE_TOKEN
}
}, function (error, response, body) {
if (!error && response.statusCode == 200) {
var user = JSON.parse(body);
if (user.first_name.length > 0) {
callback(user);
} else {
console.log("Cannot get data for fb user with id",
userId);
}
} else {
console.error(response.error);
}
});
}
}