Created
January 3, 2023 15:16
-
-
Save skolo-online/2cef75120a7ecd6e09f887348a3b912b to your computer and use it in GitHub Desktop.
Send a WhatsApp message
This file contains hidden or 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
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