Created
April 27, 2016 09:26
-
-
Save mrtopf/3b63c5eb1e43a518a5e21c9d683f352e to your computer and use it in GitHub Desktop.
Die send_image()-Funktion für den Messenger-Bot
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_image(recipient_id, image_url): | |
"""send an image to a recipient""" | |
recipient = { 'id' : recipient_id } | |
# create an image object | |
image = { 'url' : image_url } | |
# add the image object to an attachment of type "image" | |
attachment = { | |
'type' : 'image', | |
'payload' : image | |
} | |
# add the attachment to a message instead of "text" | |
message = { 'attachment' : attachment } | |
# now create the final payload with the recipient | |
payload = { | |
'recipient' : recipient, | |
'message' : message | |
} | |
send(payload) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment