دليل واجهات البرمجة التطبيقية (API)
يمكنك استخدام الأكواد المجهزة أدناه لتطبيق الربط المباشر مع مختلف لغات البرمجة.
POST
/messages/send_otp
Authentication & OTP
مثال إرسال OTP باستخدام مكتبة Axios في Node.js
const axios = require('axios');
const sendOtp = async () => {
try {
const response = await axios.post('https://your-domain.com/api/messages/send_otp', {
to: '+966500000000',
channel: 'whatsapp',
type: 'otp',
body: 'رمز التحقق الخاص بك هو: 1234'
}, {
headers: {
'Authorization': 'Bearer YOUR_API_TOKEN',
'Content-Type': 'application/json'
}
});
console.log(response.data);
} catch (error) {
console.error(error.response ? error.response.data : error.message);
}
};
sendOtp();
POST
/messages/send
General Messaging
مثال إرسال رسالة عامة باستخدام Axios
const axios = require('axios');
axios.post('https://your-domain.com/api/messages/send', {
to: '+966500000000',
channel: 'whatsapp',
type: 'text',
body: 'أهلاً بك، شكراً لتواصلك معنا.',
name_customer: 'أحمد علي'
}, {
headers: {
'Authorization': 'Bearer YOUR_API_TOKEN',
'Content-Type': 'application/json'
}
}).then(res => console.log(res.data)).catch(err => console.error(err));
POST
/messages/send_order_status
Notifications & Status
مثال لتحديث حالة الطلب داخل تطبيق فلاتر
import 'dart:convert';
import 'package:http/http.dart' as http;
Future<void> updateOrderStatus() async {
final url = Uri.parse('https://your-domain.com/api/messages/send_order_status');
await http.post(
url,
headers: {
'Authorization': 'Bearer YOUR_API_TOKEN',
'Content-Type': 'application/json',
},
body: jsonEncode({
'to': '+966500000000',
'channel': 'whatsapp',
'type': 'text',
'name_customer': 'محمد أحمد',
'order_id': '1052',
'status': 'تم الشحن',
}),
);
}
POST
/messages/send_file_lab
File Management
مثال إرسال ملف باستخدام HttpClient في C#
using System;
using System.Net.Http;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
class Program
{
static async Task Main()
{
var client = new HttpClient();
client.DefaultRequestHeaders.Add("Authorization", "Bearer YOUR_API_TOKEN");
var payload = new
{
to = "+966500000000",
channel = "whatsapp",
type = "file",
path = "https://example.com/reports/report_123.pdf",
user = "سارة محمود"
};
var json = JsonSerializer.Serialize(payload);
var content = new StringContent(json, Encoding.UTF8, "application/json");
var response = await client.PostAsync("https://your-domain.com/api/messages/send_file_lab", content);
var result = await response.Content.ReadAsStringAsync();
Console.WriteLine(result);
}
}
POST
/messages/send_complete_account
Notifications & Status
إرسال قوالب الترحيب وتأكيد الحسابات.
{
"to": "+966500000000",
"channel": "whatsapp",
"type": "text",
"name_customer": "خالد عبدالله",
"test_name": "تفعيل الحساب",
"tok": "884920"
}