نمونه کد پایتون
برای ارسال درخواست در پایتون، پیشنهاد میکنیم از کتابخانه محبوب requests استفاده کنید.
پیشنیازها
pip install requests
اسکریپت ارسال (flashcall)
send_request.py
import requests
import json
# تنظیمات اولیه
API_URL = "[https://gateway.ferzz.ir/send](https://gateway.ferzz.ir/send)"
TOKEN = "YOUR_ACCESS_TOKEN" # توکن خود را اینجا قرار دهید
def send_notification(destination, action, payload):
headers = {
"Content-Type": "application/json",
"User-Agent": "PythonClient/1.0"
}
data = {
"token": TOKEN,
"destination": destination,
"action": action,
"payload": payload
}
try:
response = requests.post(API_URL, json=data, headers=headers)
# بررسی کد وضعیت HTTP
if response.status_code == 200:
print("✅ موفقیت:", response.json())
else:
print(f"❌ خطا ({response.status_code}):", response.text)
except Exception as e:
print("خطای ارتباطی:", str(e))
# --- استفاده از تابع ---
# مثال ۱: ارسال فلشکال
send_notification(
destination="989123456789",
action="flashcall",
payload={"code": "12345"}
)