Skip to content

Instantly share code, notes, and snippets.

@mrtopf
Created April 27, 2016 09:26
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 mrtopf/3b63c5eb1e43a518a5e21c9d683f352e to your computer and use it in GitHub Desktop.
Save mrtopf/3b63c5eb1e43a518a5e21c9d683f352e to your computer and use it in GitHub Desktop.
Die send_image()-Funktion für den Messenger-Bot
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