Skip to content

Instantly share code, notes, and snippets.

@skolo-online
Created January 3, 2023 15:16
Show Gist options
  • Save skolo-online/2cef75120a7ecd6e09f887348a3b912b to your computer and use it in GitHub Desktop.
Save skolo-online/2cef75120a7ecd6e09f887348a3b912b to your computer and use it in GitHub Desktop.
Send a WhatsApp message
import requests
phoneNumber = '27738892232'
message = 'Hello there, this was sent from Django'
token = 'Bearer xxxxx-your-whatsapp-token-goes-here-xxxxxxxxxxxx'
url = 'https://graph.facebook.com/v15.0/110244361711861/messages'
def sendWhastAppMessage(phoneNumber, message):
headers = {"Authorization": token}
payload = { "messaging_product": "whatsapp",
"recipient_type": "individual",
"to": phoneNumber,
"type": "text",
"text": {"body": message}
}
response = requests.post(url, headers=headers, json=payload)
return response.json()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment