Jednoduché SMS API
Využijte již existující knihovny nebo připravte vlastní napojení svého systému na naše moderní cloudové rozhraní.
Jak to funguje?
Přihlaste se do webové administrace a získejte API klíč.
API klíč vložte do HTTP požadavku nebo do existující knihovny
SMS zprávy můžete nyní odesílat automatizovaně
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('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');
}