Skip to content

Instantly share code, notes, and snippets.

@enginebai
Created May 17, 2018 23:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save enginebai/f7af2ff9ca7f7fc6ba9e02c525cfc702 to your computer and use it in GitHub Desktop.
Save enginebai/f7af2ff9ca7f7fc6ba9e02c525cfc702 to your computer and use it in GitHub Desktop.
def send_fb_message(to, message):
post_message_url = 'https://graph.facebook.com/v2.6/me/messages?access_token={token}'.format(token=config.FB_TOKEN)
response_message = json.dumps({"recipient":{"id": to},
"message":{"text":message}})
req = requests.post(post_message_url,
headers={"Content-Type": "application/json"},
data=response_message)
print("[{}] Reply to {}: {}", req.status_code, to, message)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment