استخدم API لإرسال الرسائل النصية من أي تطبيق
جميع الطلبات تتطلب Basic Auth باستخدام بيانات الدخول من التطبيق:
أو إرسالها مباشرة مع cURL: -u "username:password"
إرسال رسالة نصية عبر Cloud Server:
Content-Type: application/json Authorization: Basic base64(username:password)
| الحقل | النوع | إجباري | الوصف |
|---|---|---|---|
phoneNumbers |
array | نعم | قائمة الأرقام (مثال: ["+966590042734"]) |
textMessage.text |
string | نعم | نص الرسالة |
simNumber |
int | لا | رقم الشريحة (1 أو 2). يحذف للشريحة الافتراضية |
curl -X POST https://api.sms-gate.app/3rdparty/v1/messages \
-u "username:password" \
-H "Content-Type: application/json" \
-d '{
"phoneNumbers": ["+966590042734"],
"textMessage": {
"text": "مرحبا من API"
},
"simNumber": 1
}'
<?php
$ch = curl_init('https://api.sms-gate.app/3rdparty/v1/messages');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPAUTH => CURLAUTH_BASIC,
CURLOPT_USERPWD => 'username:password',
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => json_encode([
'phoneNumbers' => ['+966590042734'],
'textMessage' => ['text' => 'مرحبا من API'],
'simNumber' => 1,
]),
CURLOPT_HTTPHEADER => ['Content-Type: application/json'],
]);
$res = curl_exec($ch);
curl_close($ch);
echo $res;
<?php
$data = json_encode([
'phoneNumbers' => ['+966590042734'],
'textMessage' => ['text' => 'مرحبا'],
'simNumber' => 1,
]);
$opt = [
'http' => [
'method' => 'POST',
'header' => "Authorization: Basic " . base64_encode('username:password') . "\r\nContent-Type: application/json\r\n",
'content' => $data,
]
];
echo file_get_contents('https://api.sms-gate.app/3rdparty/v1/messages', false, stream_context_create($opt));
const res = await fetch('https://api.sms-gate.app/3rdparty/v1/messages', {
method: 'POST',
headers: {
'Authorization': 'Basic ' + btoa('username:password'),
'Content-Type': 'application/json',
},
body: JSON.stringify({
phoneNumbers: ['+966590042734'],
textMessage: { text: 'مرحبا' },
simNumber: 1,
}),
});
const data = await res.json();
console.log(data);
{
"id": "abc123...",
"deviceId": "5xsIyDR15ZjLD6aSwq6Nd",
"state": "Pending",
"recipients": [
{ "phoneNumber": "+966590042734", "state": "Pending" }
],
"textMessage": { "text": "مرحبا" }
}
curl -u "username:password" \ "https://api.sms-gate.app/3rdparty/v1/messages?limit=10"
| الحقل | الوصف |
|---|---|
id |
معرف فريد للـ webhook |
url |
رابط الاستقبال (HTTPS) |
event |
نوع الحدث |
| الحدث | المعنى |
|---|---|
sms:received | 📩 وصول رسالة للجهاز |
sms:sent | 📤 إرسال رسالة |
sms:delivered | ✅ وصول الرسالة للمستلم |
sms:failed | ❌ فشل الإرسال |
curl -X POST https://api.sms-gate.app/3rdparty/v1/webhooks \
-u "username:password" \
-H "Content-Type: application/json" \
-d '{
"id": "wh-main",
"url": "https://your-site.com/webhook.php",
"event": "sms:received"
}'
curl -u "username:password" "https://api.sms-gate.app/3rdparty/v1/webhooks"
curl -X DELETE -u "username:password" \ "https://api.sms-gate.app/3rdparty/v1/webhooks/wh-main"