28 lines
652 B
Python
28 lines
652 B
Python
import requests
|
|
from django.conf import settings
|
|
|
|
|
|
def send_sms_otp(mobile, code):
|
|
url = "https://s.api.ir/api/sw1/SmsOTP"
|
|
|
|
headers = {
|
|
"Authorization": f"Bearer {settings.API_TOKEN_OTP_SMS}",
|
|
"Content-Type": "application/json"
|
|
}
|
|
|
|
data = {
|
|
"code": code,
|
|
"mobile": mobile,
|
|
"template": 2
|
|
}
|
|
|
|
try:
|
|
response = requests.post(url, json=data, headers=headers, timeout=10)
|
|
|
|
if response.status_code == 200:
|
|
result = response.json()
|
|
return bool(result.get("success"))
|
|
return False
|
|
|
|
except requests.exceptions.RequestException:
|
|
return False |