reporter
This commit is contained in:
28
2025-11-30 final reporter/Whatsapptestsendin.py
Normal file
28
2025-11-30 final reporter/Whatsapptestsendin.py
Normal file
@@ -0,0 +1,28 @@
|
||||
import os
|
||||
import requests
|
||||
from dotenv import load_dotenv
|
||||
|
||||
load_dotenv()
|
||||
|
||||
TOKEN = os.getenv("WHATSAPP_TOKEN")
|
||||
PHONE_NUMBER_ID = os.getenv("WHATSAPP_PHONE_NUMBER_ID")
|
||||
RECIPIENT = os.getenv("WHATSAPP_RECIPIENT_NUMBER")
|
||||
|
||||
def send_whatsapp_message(text):
|
||||
url = f"https://graph.facebook.com/v22.0/{PHONE_NUMBER_ID}/messages"
|
||||
headers = {
|
||||
"Authorization": f"Bearer {TOKEN}",
|
||||
"Content-Type": "application/json"
|
||||
}
|
||||
data = {
|
||||
"messaging_product": "whatsapp",
|
||||
"to": RECIPIENT,
|
||||
"type": "text",
|
||||
"text": {"body": text}
|
||||
}
|
||||
|
||||
r = requests.post(url, headers=headers, json=data)
|
||||
print("Status:", r.status_code)
|
||||
print("Response:", r.text)
|
||||
|
||||
send_whatsapp_message("Ahoj Vlado! Test zpráva přes WhatsApp API 🔔")
|
||||
Reference in New Issue
Block a user