Message အခြေအနေကိုစစ်ဆေးပါ။
status check endpoint ကို အသုံးပြု၍ သင့်မက်ဆေ့ဂျ်များ၏ ပေးပို့မှုအခြေအနေကို ခြေရာခံပါ။
အဆုံးမှတ်
တောင်းဆိုခြင်း။
URL ကန့်သတ်ချက်များ
| ကန့်သတ်ချက် | ရိုက် | လိုအပ်သည် | ဖော်ပြချက် |
|---|---|---|---|
messageId |
string | ဟုတ်တယ် | ပေးပို့တုံ့ပြန်မှု |
စစ်မှန်ကြောင်းအထောက်အထားပြခြင်း။
အထောက်အထားစိစစ်ခြင်းနည်းလမ်းသုံးမျိုးထဲမှ တစ်ခုခုကို အသုံးပြုပါ-
တုံ့ပြန်မှု
အခြေခံတုံ့ပြန်မှု
{
"messagelistId": 123456,
"messageId": "abc123def456",
"deliverystatus": "delivered",
"partscount": 1,
"cost": 0.05
}
တုံ့ပြန်မှုနယ်ပယ်များ
| လယ် | ရိုက် | ဖော်ပြချက် |
|---|---|---|
messagelistId |
ကိန်းပြည့် | Batch identifier |
messageId |
string | ထူးခြားသော မက်ဆေ့ချ် သတ်မှတ်သူ |
deliverystatus |
string | လက်ရှိပေးပို့မှုအခြေအနေ |
အစိတ်အပိုင်းများ |
ကိန်းပြည့် | မက်ဆေ့ခ်ျအပိုင်း |
ကုန်ကျစရိတ် |
နံပါတ် | မက်ဆေ့ချ်အတွက် ငွေကြေးယူနစ် |
တိုးချဲ့တုံ့ပြန်မှု (နောက်ပြန်ဆွဲခြင်းနှင့်အတူ)
နောက်ပြန်ဆုတ်ခြင်းကို စီစဉ်သတ်မှတ်သည့်အခါ၊ တုံ့ပြန်မှုတွင် နောက်ထပ်အကွက်များ ပါဝင်သည်-
{
"messagelistId": 123456,
"messageId": "abc123def456",
"deliverystatus": "delivered",
"partscount": 1,
"cost": 0.05,
"fallbacks": [
{
"type": "sms",
"status": "not_used"
}
],
"extendedStatuses": {
"viber": "delivered",
"sms": "not_used"
},
"rate": 0.05,
"rateAmount": 0.05,
"rateCurrency": "USD",
"billAmount": 0.05,
"billCurrency": "USD"
}
ပေးပို့မှုအခြေအနေတန်ဖိုးများ
| အဆင့်အတန်း | ဖော်ပြချက် |
|---|---|
စီစဉ်ထားသည် |
ပို့ရန်တန်းစီထားသည်။ |
စီမံဆောင်ရွက်ခြင်း |
လောလောဆယ် |
delivered |
အောင်မြင်စွာ ပေးပို့ |
လက်မလွှတ်နိုင်သော |
ပေးပို့မှု မအောင်မြင်ပါ၊ မက်ဆေ့ချ်ကို ပယ်ချ |
အမြဲတမ်း |
ဆက်တိုက်အမှားအယွင်း |
အခြေအနေ Lifecycle
graph LR
A[scheduled] --> B[processing]
B --> C[delivered]
B --> D[undeliverable]
B --> E[permanenterror]
စီစဉ်ထားပါတယ်။
မက်ဆေ့ဂျ်ကို လက်ခံပြီး ပေးပို့ရန် တန်းစီနေသည်-
ဆောင်ရွက်နေပါသည်။
လက်ခံသူထံ လောလောဆယ် မက်ဆေ့ဂျ်ကို ပို့နေပါသည်-
ပို့ဆောင်ပေးခဲ့ပါသည်။
မက်ဆေ့ဂျ်ကို လက်ခံသူထံ အောင်မြင်စွာပေးပို့ပြီးပါပြီ-
မရနိုင်ပါ။
မက်ဆေ့ဂျ်ကို ပေးပို့၍မရပါ (မမှန်ကန်သောနံပါတ်၊ ကွန်ရက်အမှားအယွင်း)။
အမြဲတမ်းအမှား
ဆက်တိုက်ပေးပို့ခြင်းပြဿနာများကြောင့် မက်ဆေ့ချ်ကို တန်းစီမှ ဖယ်ရှားလိုက်သည်-
မက်ဆေ့ဂျ်များစွာကို စစ်ဆေးပါ။
သင့်အပလီကေးရှင်းရှိ မက်ဆေ့ခ်ျများစွာအတွက် အခြေအနေကို စစ်ဆေးပါ-
// JavaScript example
async function checkMessageStatuses(messageIds) {
const statuses = await Promise.all(
messageIds.map(async (messageId) => {
const response = await fetch(
`https://restapi.smsbat.com/bat/message/${messageId}`,
{
headers: {
'X-Authorization-Key': 'your-api-key'
}
}
);
return response.json();
})
);
return statuses;
}
// Usage
const messageIds = ['abc123', 'def456', 'ghi789'];
const statuses = await checkMessageStatuses(messageIds);
statuses.forEach(status => {
console.log(`Message ${status.messageId}: ${status.deliverystatus}`);
});
အခြေအနေမွမ်းမံမှုများအတွက် မဲစာရင်း
ပေးပို့မှုကို ခြေရာခံရန် status endpoint ကို စစ်တမ်းကောက်ယူပါ-
// Poll every 5 seconds until delivered
async function waitForDelivery(messageId, maxAttempts = 12) {
for (let i = 0; i < maxAttempts; i++) {
const response = await fetch(
`https://restapi.smsbat.com/bat/message/${messageId}`,
{
headers: { 'X-Authorization-Key': 'your-api-key' }
}
);
const status = await response.json();
if (status.deliverystatus === 'delivered') {
return { success: true, status };
}
if (status.deliverystatus === 'undeliverable' ||
status.deliverystatus === 'permanenterror') {
return { success: false, status };
}
// Wait 5 seconds before next check
await new Promise(resolve => setTimeout(resolve, 5000));
}
// Timeout after 60 seconds
return { success: false, timeout: true };
}
Webhook Alternative
စစ်တမ်းကောက်ယူမည့်အစား၊ အချိန်နှင့်တစ်ပြေးညီ အခြေအနေအပ်ဒိတ်များအတွက် webhooks ကိုသုံးပါ-
POST https://your-server.com/webhook
{
"messageId": "abc123def456",
"deliverystatus": "delivered",
"timestamp": "2025-01-23T10:30:00Z",
"cost": 0.05
}
webhook URL ကို စီစဉ်သတ်မှတ်ရန် သင့်အကောင့်မန်နေဂျာထံ ဆက်သွယ်ပါ။
အကောင်အထည်ဖော်မှု ဥပမာများ
Python
import requests
import time
def check_status(message_id, api_key):
url = f"https://restapi.smsbat.com/bat/message/{message_id}"
headers = {"X-Authorization-Key": api_key}
response = requests.get(url, headers=headers)
return response.json()
def wait_for_delivery(message_id, api_key, timeout=60):
"""Poll until delivered or timeout"""
start_time = time.time()
while time.time() - start_time < timeout:
status = check_status(message_id, api_key)
if status['deliverystatus'] == 'delivered':
return {'success': True, 'status': status}
if status['deliverystatus'] in ['undeliverable', 'permanenterror']:
return {'success': False, 'status': status}
time.sleep(5)
return {'success': False, 'timeout': True}
# Usage
message_id = "abc123def456"
result = wait_for_delivery(message_id, "your-api-key")
if result['success']:
print(f"Message delivered! Cost: {result['status']['cost']}")
else:
print("Message delivery failed or timeout")
PHP
<?php
function checkStatus($messageId, $apiKey) {
$url = "https://restapi.smsbat.com/bat/message/" . $messageId;
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"X-Authorization-Key: " . $apiKey
]);
$response = curl_exec($ch);
curl_close($ch);
return json_decode($response, true);
}
function waitForDelivery($messageId, $apiKey, $timeout = 60) {
$startTime = time();
while (time() - $startTime < $timeout) {
$status = checkStatus($messageId, $apiKey);
if ($status['deliverystatus'] === 'delivered') {
return ['success' => true, 'status' => $status];
}
if (in_array($status['deliverystatus'],
['undeliverable', 'permanenterror'])) {
return ['success' => false, 'status' => $status];
}
sleep(5);
}
return ['success' => false, 'timeout' => true];
}
// Usage
$messageId = "abc123def456";
$result = waitForDelivery($messageId, "your-api-key");
if ($result['success']) {
echo "Message delivered! Cost: " . $result['status']['cost'];
} else {
echo "Message delivery failed or timeout";
}
Node.js
const axios = require('axios');
async function checkStatus(messageId, apiKey) {
const response = await axios.get(
`https://restapi.smsbat.com/bat/message/${messageId}`,
{
headers: { 'X-Authorization-Key': apiKey }
}
);
return response.data;
}
async function waitForDelivery(messageId, apiKey, timeout = 60000) {
const startTime = Date.now();
while (Date.now() - startTime < timeout) {
const status = await checkStatus(messageId, apiKey);
if (status.deliverystatus === 'delivered') {
return { success: true, status };
}
if (['undeliverable', 'permanenterror'].includes(
status.deliverystatus
)) {
return { success: false, status };
}
// Wait 5 seconds
await new Promise(resolve => setTimeout(resolve, 5000));
}
return { success: false, timeout: true };
}
// Usage
const messageId = 'abc123def456';
const result = await waitForDelivery(messageId, 'your-api-key');
if (result.success) {
console.log(`Message delivered! Cost: ${result.status.cost}`);
} else {
console.log('Message delivery failed or timeout');
}
အကောင်းဆုံးအလေ့အကျင့်များ
မဲစာရင်းအကြိမ်ရေ
- ✅ 5-10 စက္ကန့်တိုင်း စစ်တမ်းကောက်ယူပါ။
- ✅ exponential backoff ကို အကောင်အထည်ဖော်ပါ။
- ✅ သင့်လျော်သောအချိန်ကိုသတ်မှတ်ပါ (60-120 စက္ကန့်)
- ❌ တစ်စက္ကန့်ကို တစ်ကြိမ်ထက်ပိုပြီး မဲမပေးပါ။
- ❌ ရက်အကန့်အသတ်မရှိ မဲမပေးပါ။
မှားယွင်းကိုင်တွယ်ခြင်း။
async function checkStatusWithRetry(messageId, apiKey, retries = 3) {
for (let i = 0; i < retries; i++) {
try {
const response = await fetch(
`https://restapi.smsbat.com/bat/message/${messageId}`,
{
headers: { 'X-Authorization-Key': apiKey }
}
);
if (!response.ok) {
throw new Error(`HTTP ${response.status}`);
}
return await response.json();
} catch (error) {
if (i === retries - 1) throw error;
// Wait before retry (exponential backoff)
await new Promise(resolve =>
setTimeout(resolve, Math.pow(2, i) * 1000)
);
}
}
}
သိမ်းဆည်းခြင်း။
API ခေါ်ဆိုမှုများကို လျှော့ချရန် ကက်ရှ် အခြေအနေ ရလဒ်များ
const statusCache = new Map();
async function getCachedStatus(messageId, apiKey, cacheTTL = 30000) {
const cached = statusCache.get(messageId);
if (cached && Date.now() - cached.timestamp < cacheTTL) {
return cached.status;
}
const status = await checkStatus(messageId, apiKey);
statusCache.set(messageId, {
status,
timestamp: Date.now()
});
return status;
}
Batch Processing
မက်ဆေ့ချ်များစွာကို စစ်ဆေးသည့်အခါ အစုလိုက်တောင်းဆိုမှုများ-
async function checkBatchStatus(messageIds, apiKey, batchSize = 10) {
const results = [];
for (let i = 0; i < messageIds.length; i += batchSize) {
const batch = messageIds.slice(i, i + batchSize);
const batchResults = await Promise.all(
batch.map(id => checkStatus(id, apiKey))
);
results.push(...batchResults);
// Rate limiting
if (i + batchSize < messageIds.length) {
await new Promise(resolve => setTimeout(resolve, 1000));
}
}
return results;
}
Cases ကိုအသုံးပြုပါ။
အော်ဒါအတည်ပြုခြင်း။
မှာယူမှုအတည်ပြုချက်မက်ဆေ့ဂျ်ပေးပို့မှုကို ခြေရာခံပါ-
const orderMessage = await sendMessage({
to: customer.phone,
text: `Order #${orderId} confirmed`
});
// Wait for delivery
const result = await waitForDelivery(orderMessage.messageId, apiKey);
if (result.success) {
await updateOrder(orderId, { notificationSent: true });
} else {
await scheduleRetry(orderId);
}
Two-Factor Authentication
အချိန်မကုန်မီ OTP ပေးပို့မှုကို အတည်ပြုပါ-
const otpMessage = await sendOTP(userPhone, otpCode);
// Poll for delivery
const delivered = await waitForDelivery(
otpMessage.messageId,
apiKey,
30 // 30 second timeout
);
if (!delivered.success) {
// Send via alternative channel
await sendEmailOTP(userEmail, otpCode);
}
စျေးကွက်ရှာဖွေရေး ကမ်ပိန်းများ
ကမ်ပိန်းစာတိုပေးပို့မှုနှုန်းများကို ခြေရာခံပါ-
const messageIds = await sendCampaign(recipientList);
// Check all statuses after 5 minutes
setTimeout(async () => {
const statuses = await checkBatchStatus(messageIds, apiKey);
const delivered = statuses.filter(s =>
s.deliverystatus === 'delivered'
).length;
console.log(`Delivery rate: ${delivered / statuses.length * 100}%`);
}, 5 * 60 * 1000);
နောက်အဆင့်များ
- Send Message - စာတိုပေးပို့နည်းကို လေ့လာပါ။
- ပို့ဆောင်မှုအခြေအနေလမ်းညွှန် - ပေးပို့မှုအခြေအနေများကို နားလည်ပါ။
- Fallback Strategies - မှားယွင်းမှုများကို စီစဉ်သတ်မှတ်ပါ။