smswhatsappservice/send_otp.py

27 lines
818 B
Python
Raw Normal View History

2026-09-20 13:27:37 +00:00
import requests
import json
# Your credentials and details
authkey = "563180T1AlanJm6aa942b9P1" # Extracted from tokenAuth in CERD.TXT
mobile = "919600494039" # Mobile number with country code (assuming India 91)
template_id = "YOUR_TEMPLATE_ID" # You must replace this with your actual Template ID from MSG91 dashboard
url = f"https://control.msg91.com/api/v5/otp?template_id={template_id}&mobile={mobile}&authkey={authkey}"
payload = json.dumps({
# Add any custom variables defined in your template here
# "Param1": "value1",
# "company_name": "MyCompany"
})
headers = {
'Content-Type': 'application/json'
}
print(f"Sending OTP to {mobile}...")
response = requests.request("POST", url, headers=headers, data=payload)
print("Status Code:", response.status_code)
print("Response Body:", response.text)