public
Created

express facebook verify subscription creation routes

  • Download Gist
gistfile1.js
JavaScript
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
app.post('/facebook/realtimeupdates', function(req, res) {
f = ':/facebook/realtimeupdates POST cb:';
 
var object = req.param('object');
var entry = req.param('entry');
log.finer(__filename+f+'new notifications');
log.finest(__filename+f+'object=('+object+')');
log.finest(__filename+f+'entry=('+entry+')');
 
res.send(200);
});
 
app.get('/facebook/realtimeupdates', function(req, res) {
f = ':/facebook/realtimeupdates GET cb:';
 
//TODO read and implement ff
//The end point should first verify the verify_token value is what you passed to Facebook, then return the hub.challenge value. This verification technique prevents malicious apps from using the real-time feature as tool for distributed denial-of-service (DDoS) attacks.
 
var mode = req.param('hub.mode'),
challenge = req.param('hub.challenge'),
verify_token = req.param('hub.verify_token');
 
log.finer(__filename+f+'subscription verification called');
log.finest(__filename+f+'mode=('+mode+')');
log.finest(__filename+f+'challenge=('+challenge+')');
log.finest(__filename+f+'verify_token=('+verify_token+')');
 
res.write('challenge'); // "return" the challenge this way?
res.end();
});

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.