Created
August 28, 2016 21:39
-
-
Save jesuscast/a49af02d1d6ed2d3521b0c265e5665df to your computer and use it in GitHub Desktop.
This file contains hidden or 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
function sendTextMessage(sender, text) { | |
let messageData = { text:text } | |
request({ | |
url: 'https://graph.facebook.com/v2.6/me/messages', | |
qs: {access_token:token}, | |
method: 'POST', | |
json: { | |
recipient: {id:sender}, | |
message: messageData, | |
} | |
}, function(error, response, body) { | |
if (error) { | |
console.log('Error sending messages: ', error) | |
} else if (response.body.error) { | |
console.log('Error: ', response.body.error) | |
} | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment