Last active
February 1, 2017 08:13
-
-
Save dolphinsue319/99bacc09762377143e43c567767fb863 to your computer and use it in GitHub Desktop.
send message to Facebook
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
def send_message(recipient_id, message_text): | |
params = { | |
"access_token": os.environ["PAGE_ACCESS_TOKEN"] | |
} | |
headers = { | |
"Content-Type": "application/json" | |
} | |
data = json.dumps({ | |
"recipient": { | |
"id": recipient_id | |
}, | |
"message": { | |
"text": message_text | |
} | |
}) | |
r = requests.post("https://graph.facebook.com/v2.6/me/messages", params=params, headers=headers, data=data) | |
if r.status_code != 200: | |
log(r.status_code) | |
log(r.text) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment