Skip to content

Instantly share code, notes, and snippets.

@teenoh
Created November 2, 2017 20:37
Show Gist options
  • Save teenoh/abb9f9cf550a112dfec8afa156d71328 to your computer and use it in GitHub Desktop.
Save teenoh/abb9f9cf550a112dfec8afa156d71328 to your computer and use it in GitHub Desktop.
def send_gif_message(recipient_id, message):
gif_url = search_gif(message)
data = json.dumps({
"recipient": {"id": recipient_id},
"message": {
"attachment": {
"type": "image",
"payload": {
"url": gif_url
}
}}
})
params = {
"access_token": <PAGE_ACCESS_TOKEN>
}
headers = {
"Content-Type": "application/json"
}
r = requests.post("https://graph.facebook.com/v2.6/me/messages",
params=params, headers=headers, data=data)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment