forked from steadicat/swarmation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fb.js
36 lines (31 loc) · 756 Bytes
/
fb.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
35
36
var sys = require('sys')
var request = require('request')
var fb = {}
function response(cb) {
return function(err, resp, body) {
if (err) {
sys.log('FB: Error: ' + resp + ' ' + JSON.stringify(body))
return cb(err)
}
sys.log('FB: Response: ' + JSON.stringify(body))
cb(null, body)
}
}
fb.get = function(path, token, cb) {
sys.log('FB: Get ' + path)
request.get({
uri: 'https://graph.facebook.com/' + path,
qs: { access_token: token },
json: true,
}, response(cb))
}
fb.post = function(path, token, data, cb) {
data.access_token = token
sys.log('FB: Post ' + path)
request.post({
uri: 'https://graph.facebook.com/'+path,
form: data,
json: true
}, response(cb))
}
module.exports = fb