This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Creating an infinite scroll with react native |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
functions: | |
fbverify: | |
handler: handler.fbVerify | |
events: | |
- http: | |
path: fbhook | |
method: GET | |
integration: lambda | |
fbmessages: | |
handler: handler.fbMessages |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports.fbVerify = (event, context, callback) => { | |
if (event.query['hub.mode'] === 'subscribe' && | |
event.query['hub.verify_token'] === 'sometoken') { | |
console.log("Validating webhook"); | |
return callback(null, parseInt(event.query['hub.challenge'])); | |
} else { | |
console.error("Failed validation. Make sure the validation tokens match."); | |
return callback('Invalid token'); | |
} | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports.fbMessages = (event, context, callback) => { | |
event.body.entry.map((entry) => { | |
entry.messaging.map((messagingItem) => { | |
if (messagingItem.message && messagingItem.message.text) { | |
const url = `https://graph.facebook.com/v2.6/me/messages?access_token=<your access token here>`; | |
const responsePayload = { | |
recipient: { | |
id: messagingItem.sender.id | |
}, |
OlderNewer