Automatizace odesílání zpráv
Jak funguje odesílání zpráv přes API?
Jedná se o rozhraní, které dovoluje strojovým způsobem přijímat požadavky na odesílání zpráv. Díky tomu lze napojit libovolný systém nebo aplikaci a zprávy odesílat zcela automatizovaně.
Co vše mohu s API dělat?
Odesílat je možné jak SMS, tak Viber, WhatsApp zprávy nebo interaktivní RCS zprávy.
Jak to funguje?
Založte si účet
Registrace je zdarma. Budete potřebovat jen e-mail a heslo.
Dobjte si kredit a získejte API klíč
Po založení účtu si můžete dobít kredit a získat API klíč. Kredit lze dobít bankovním převodem nebo platební kartou.
Použijte svůj API klíč
Váš API klíč funguje jako přihlašovací údaje pro odesílání zpráv.
Nyní napojte svůj systém na naše API a můžete odesílat zprávy. K dispozici máte ukázky kódů nebo můžete existující knihovny pro různé programovací jazyky.
Příklady použití
- PHP
- JavaScript SDK
- Node.js
<?php
$apikey = 'your-api-key-here'; // Replace with your actual API key
$number = 'phone-number-here'; // Replace with the target phone number
$text = 'message-text-here'; // Replace with the message text
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.smsmngr.com/v2/message');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode(array(
'to' => array(array('phone_number' => $number)),
'body' => $text
)));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'x-api-key:' . $apikey
));
// Execute the request and capture the response
$response = curl_exec($ch);
curl_close($ch);
// Process the response
$response = json_decode($response, true);
if ($response['accepted'] && $response['accepted'][0]) { // SMS was sent successfully
echo 'Status: Accepted';
echo 'ID: ' . $response['accepted'][0]['message_id'];
} else {
echo 'Status: Rejected';
}
const SmsManager = require('smsmanager-js-api');
const sender = new SmsManager('your-api-key-here');
sender.send('phone-number-here', 'Your message text')
.then(result => {
if (result.success) {
console.log('SMS sent successfully. Message ID:', result.messageId);
} else {
console.log('Failed to send SMS');
}
})
.catch(error => {
console.error('Error sending SMS:', error);
});
const response = await fetch('https://api.smsmngr.com/v2/message', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'x-api-key': 'your-api-key-here'
},
body: JSON.stringify({
to: [{
phone_number: 'phone-number-here'
}],
body: 'message-text-here'
})
});
const responseText = await response.json();
if(response.accepted && response.accepted[0]){ // SMS was sent successfully
console.log('Status: Accepted');
console.log('ID:', response.accepted[0].message_id);
}
else{
console.log('Status: Rejected');
}