49 lines
1.7 KiB
Python
49 lines
1.7 KiB
Python
from dotenv import load_dotenv
|
|
import os
|
|
from ghasedak_sms import Ghasedak
|
|
|
|
load_dotenv(".env.local")
|
|
sms_api = Ghasedak(api_key=os.getenv("SMS_API_KEY"))
|
|
|
|
### ارسال پیامک تکی
|
|
# response = sms_api.send_single_sms(message=hello, world!, receptor='0935*****', linenumber='3000*****', senddate='', checkid='')
|
|
|
|
### ارسال پیامک گروهی
|
|
# response = sms_api.send_bulk_sms(message='hello, world!', receptors=['09xxxxxxxxx', '09xxxxxxxxx'], linenumber='3000*****', senddate='', checkid='')
|
|
|
|
### ارسال پیام otp
|
|
|
|
#response = sms_api.send_otp_sms(receptor='09359****', message='OTP message')
|
|
|
|
|
|
|
|
import ghasedak_sms
|
|
|
|
# Initialize the Ghasedak API client with your API key
|
|
sms_api = ghasedak_sms.Ghasedak(api_key="Your_API_KEY")
|
|
|
|
# Define the OTP code and the recipient's phone number
|
|
otp_code = "123456" # Replace with the generated OTP code
|
|
phone_number = "09xxxxxxxxx" # Replace with the recipient's phone number
|
|
|
|
# Create the OTP input object
|
|
otp_input = ghasedak_sms.SendOtpInput(
|
|
send_date=None, # Immediate send; use a specific datetime for scheduled send
|
|
receptors=[
|
|
ghasedak_sms.SendOtpReceptorDto(
|
|
mobile=phone_number,
|
|
# client_reference_id='optional_client_ref_id' # Optional: Add if you have a client reference ID
|
|
)
|
|
],
|
|
template_name="YourTemplateName", # Replace with your OTP template name
|
|
inputs=[
|
|
ghasedak_sms.SendOtpInput.OtpInput(param="Code", value=otp_code),
|
|
# Add more parameters if your template requires them
|
|
],
|
|
udh=False # Set to True if you need User Data Header; typically False for standard SMS
|
|
)
|
|
|
|
# Send the OTP SMS
|
|
response = sms_api.send_otp_sms(otp_input)
|
|
|