-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
28 lines (25 loc) · 887 Bytes
/
app.py
File metadata and controls
28 lines (25 loc) · 887 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import random
import requests
import string
# A function to generate otp
def generateOTP():
return ''.join(random.choices(string.digits, k=4))
def sendSMS(phone, otpcode):
to = phone
message = otpcode
template_id = 'otp' #other templates: otp_1, welcome, welcome_1, reminder, reminder_, shopping, shopping_1, confirmation, confirmation_1
server = 'https://sms.yegara.com/api2/send'
username = 'domain-name' #use your own domain name and password
password = 'password'
# Create the payload as a dictionary
payload = {
'username': username,
'password': password,
'to': to,
'message': message,
'template_id': template_id,
}
# Send a POST request to the server and get the response
response = requests.post(server, json=payload)
json_response = response.json()
print(json_response)