﷽
اولین کامیت پروژه پایاچت
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
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
|
||||
Reference in New Issue
Block a user