I need to understand how the FB Webhooks
works.
I set up a Webhook
for the new Facebook Messenger
following the guide and all works like a charm:
I create a GET
endpoint to receive the connect the API for the first time:
router.get('/fb_cb', function(req, res, next) {
if (req.query['hub.verify_token'] === 'my_token') {
res.send(req.query['hub.challenge']);
console.log('fb GET!');
} else {
res.send('Error, wrong validation token');
}
});
In my Fb pane I reached this endpoint for the first time, setting up the page, get the Page Access Token
end set up an endpoint to receive the callback:
router.post('/fb_cb', function(req, res, next) {
console.log('hook');
messaging_events = req.body.entry[0].messaging;
for (i = 0; i < messaging_events.length; i++) {
event = req.body.entry[0].messaging[i];
sender = event.sender;
if (event.message && event.message.text) {
console.log(event.sender.id);
}
}
res.sendStatus(200);
});
and all it's ok, I can chat with my page :D
Now I'm trying to do the same thing for receive user updates, so I configured the endpoint in Facebook Webhooks
, and GET
endpoint is reached without problems.
BUT, I don't receive any notification by my user when I do any action like posting content, changing personal status…
This is the current state of my subscriptions retrieved by Graph API:
data: [{
object: "user",
callback_url: "https://myapp.com/fb_cb",
fields: ["about", "about_me", "current_location", "likes", "photos", "pic", "picture", "status", "statuses", "work"],
active: true
}, {
object: "page",
callback_url: "https://myapp.com/fb_messenger_cb",
fields: ["message_deliveries", "messages", "messaging_optins", "messaging_postbacks"],
active: true
}, {
object: "application",
callback_url: "https://myapp.com/fb_app_cb",
fields: ["async_requests"],
active: true
}]
There is a way to achieve this result? What's wrong?