Bildirim Gönderme
Müşteriye şablon, e-posta ya da SMS gönderen ve gönderileni geri okuyan beş uç.
Genel Bakış
Bu uçlar bir müşteriye mesaj gönderir ve gönderileni geri okur. Üç gönderim yolu vardır: kayıtlı bir şablon, serbest bir e-posta ve serbest bir SMS.
Gönderimlerin hepsi eş zamanlıdır. Yanıt, gönderim denemesi bittikten sonra döner; kuyruğa alınmaz. Yavaş bir sağlayıcı isteğinizi de yavaşlatır.
Referans
Alıcıları Önizleme
Bir şablonun kimlere gideceğini gönderim yapmadan döndürür.
grup/ad biçiminde.email ya da sms. Verirseniz yalnız o kanalın alıcıları döner.email ve name taşır.template grup/ad biçiminde değil.curl -G 'https://panel.ornek.com/api/v1/admin/clients/42/notifications/recipients' \
-H "Authorization: Bearer $API_KEY" \
-d template=user/welcomeconst url = new URL('https://panel.ornek.com/api/v1/admin/clients/42/notifications/recipients');
url.searchParams.set('template', 'user/welcome');
const res = await fetch(url, { headers: { Authorization: `Bearer ${apiKey}` } });
const body = await res.json();$url = 'https://panel.ornek.com/api/v1/admin/clients/42/notifications/recipients?' . http_build_query(['template' => 'user/welcome']);
$ch = curl_init($url);
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . $apiKey],
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);// Gondermeden once alici var mi diye bakin: alici yoksa gonderim sent: false doner.
$preview = Api::Clients()->GetClientNotificationRecipients([
'id' => 42,
'template' => 'user/welcome',
], ['channel' => 'email']);
if (!($preview['data']['mail'] ?? [])) {
return;
}{
"data": {
"mail": [
{ "email": "[email protected]", "name": "John Doe" }
],
"sms": []
}
}Şablon Gönderme
Kayıtlı bir bildirim şablonunu müşteriye gönderir.
grup/ad biçiminde. İki parça da dolu olmalı: user/welcome.email ya da sms. Varsayılan email.true. Kimseye ulaşmayan gönderim yine 200 ile, nedeniyle birlikte false döner.sent false iken: disabled, blocked, module_not_configured, no_recipients ya da send_failed.sent false iken: İngilizce açıklama. send_failed durumunda modülün kendi hatasını taşır.template grup/ad biçiminde değil.curl -X POST 'https://panel.ornek.com/api/v1/admin/clients/42/notifications/template' \
-H "Authorization: Bearer $API_KEY" \
-H 'Content-Type: application/json' \
-d '{"template":"user/welcome","channel":"email"}'const res = await fetch('https://panel.ornek.com/api/v1/admin/clients/42/notifications/template', {
method: 'POST',
headers: {
Authorization: `Bearer ${apiKey}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({ template: 'user/welcome', channel: 'email' }),
});
const body = await res.json();$ch = curl_init('https://panel.ornek.com/api/v1/admin/clients/42/notifications/template');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . $apiKey,
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode([
'template' => 'user/welcome',
'channel' => 'email',
]),
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);$response = Api::Clients()->SendClientTemplate([
'id' => 42,
'template' => 'user/welcome',
'channel' => 'email',
]);Özel E-posta Gönderme
Şablona bağlı olmadan, serbest konu ve gövdeyle e-posta gönderir.
true. Yalnız gönderen yöneticiye giden kopya sayılmaz.sent false iken. Şablon gönderimiyle aynı kodlar.sent false iken: İngilizce açıklama.subject boş.message boş.curl -X POST 'https://panel.ornek.com/api/v1/admin/clients/42/notifications/email' \
-H "Authorization: Bearer $API_KEY" \
-H 'Content-Type: application/json' \
-d '{"subject":"Hesabinizla ilgili bir guncelleme","message":"Merhaba, talebiniz islendi.","copy_to_admin":true}'const res = await fetch('https://panel.ornek.com/api/v1/admin/clients/42/notifications/email', {
method: 'POST',
headers: {
Authorization: `Bearer ${apiKey}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
subject: 'Hesabinizla ilgili bir guncelleme',
message: 'Merhaba, talebiniz islendi.',
copy_to_admin: true,
}),
});
const body = await res.json();$ch = curl_init('https://panel.ornek.com/api/v1/admin/clients/42/notifications/email');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . $apiKey,
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode([
'subject' => 'Hesabinizla ilgili bir guncelleme',
'message' => 'Merhaba, talebiniz islendi.',
'copy_to_admin' => true,
]),
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);$response = Api::Clients()->SendClientEmail([
'id' => 42,
'subject' => 'Hesabinizla ilgili bir guncelleme',
'message' => 'Merhaba, talebiniz islendi.',
]);
// Musteriye ulasilmadiysa sent false olur; nedeni reason soyler.
$failed = !($response['data']['sent'] ?? false);Özel SMS Gönderme
Müşteriye serbest içerikli bir SMS gönderir.
true.sent false iken. SMS modülü seçili değilse module_not_configured olur.sent false iken: İngilizce açıklama.message boş.curl -X POST 'https://panel.ornek.com/api/v1/admin/clients/42/notifications/sms' \
-H "Authorization: Bearer $API_KEY" \
-H 'Content-Type: application/json' \
-d '{"message":"Merhaba, talebiniz islendi."}'const res = await fetch('https://panel.ornek.com/api/v1/admin/clients/42/notifications/sms', {
method: 'POST',
headers: {
Authorization: `Bearer ${apiKey}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({ message: 'Merhaba, talebiniz islendi.' }),
});
const body = await res.json();$ch = curl_init('https://panel.ornek.com/api/v1/admin/clients/42/notifications/sms');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . $apiKey,
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode(['message' => 'Merhaba, talebiniz islendi.']),
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);$response = Api::Clients()->SendClientSms([
'id' => 42,
'message' => 'Merhaba, talebiniz islendi.',
]);Gönderilmiş Mesajı Okuma
Daha önce gönderilmiş bir e-posta ya da SMS kaydının içeriğini döndürür. Güvenlik iletileri (parola sıfırlama, doğrulama ve transfer kodları) ve gizli işaretli kayıtlar, müşterinin Mesajlar sekmesindeki gibi boş gövdeyle ve redacted true olarak döner.
email ya da sms.redacted true ise ya da saklanan gövde okunamıyorsa boş.true: güvenlik iletisi ya da private işaretli kayıt.type ya da id eksik veya geçersiz.curl -G 'https://panel.ornek.com/api/v1/admin/clients/messages/preview' \
-H "Authorization: Bearer $API_KEY" \
-d type=email \
-d id=901const url = new URL('https://panel.ornek.com/api/v1/admin/clients/messages/preview');
url.searchParams.set('type', 'email');
url.searchParams.set('id', '901');
const res = await fetch(url, { headers: { Authorization: `Bearer ${apiKey}` } });
const body = await res.json();$url = 'https://panel.ornek.com/api/v1/admin/clients/messages/preview?' . http_build_query(['type' => 'email', 'id' => 901]);
$ch = curl_init($url);
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . $apiKey],
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);$response = Api::Clients()->GetMessagePreview([], [
'type' => 'email',
'id' => 901,
]);
$content = $response['data']['content'];Tuzaklar
Kimseye ulaşmayan gönderim de 200 döner; sent false olur ve reason nedenini söyler: şablon kapalı, bir kural engelledi, kanal için modül seçili değil, müşterinin o kanalda adresi yok ya da teslim başarısız oldu. Kontrolü önce sent'e, sonra reason'a göre yazın. Gönderen yöneticiye giden kopya gönderim sayılmaz.
Müşterinin e-postası ya da telefonu yoksa yanıt no_recipients nedeniyle sent: false olur. Böyle müşterileri baştan ayıklamak için önce önizleme ucunu çağırın ve listesi boş dönenleri atlayın.
Gönderim kuyruğa alınmaz. Toplu iş yazıyorsanız her müşteri için sağlayıcının yanıt süresini ödersiniz; zaman aşımı sınırınızı buna göre koyun.
İlgili Makaleler
Geri bildiriminiz için teşekkürler!
Yukarıda bulamadığınız her şey için destek ekibimiz her zaman yanınızda.