This commit is contained in:
2025-10-26 18:38:12 +01:00
parent 8712668ad4
commit e07296f23f
5 changed files with 157 additions and 0 deletions

40
SMS.py Normal file
View File

@@ -0,0 +1,40 @@
import requests
def send_sms_via_diafaan():
# Diafaan SMS Server configuration
server_url = "http://localhost:9710/http/send-message" # Replace with your server address
username = "admin" # Replace with your Diafaan username
password = "" # Replace with your Diafaan password
# SMS details
to_number = "420775735276" # Recipient number with country code
message = "Hello from Python via Diafaan SMS Server!"
sender_id = "" # Optional sender ID
# Prepare the request parameters
params = {
'username': username,
'password': password,
'to': to_number,
'message': message,
'from': sender_id
}
try:
# Send the HTTP GET request
response = requests.get(server_url, params=params)
# Check the response
if response.status_code == 200:
print("SMS sent successfully!")
print("Response:", response.text)
else:
print(f"Failed to send SMS. Status code: {response.status_code}")
print("Response:", response.text)
except Exception as e:
print(f"An error occurred: {str(e)}")
# Call the function
send_sms_via_diafaan()