Příklad odeslání SMS zprávy
Odeslání SMS zprávy
- PHP
- Node.js
- HTTP
<?php
$apikey = 'your-api-key-here'; // Replace with your actual API key
$number = '420777123456'; // Replace with the target phone number
$text = 'Hello world!'; // Replace with the message text
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://http-api.smsmanager.cz/Send');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query([
'apikey' => $apikey,
'number' => $number,
'text' => $text
]));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Content-Type: application/x-www-form-urlencoded'
]);
// Execute the request and capture the response
$response = curl_exec($ch);
curl_close($ch);
// Process the response
list($status, $id) = explode('|', $response);
if ($status == "OK") { // SMS was sent successfully
echo 'Status: ' . $status;
echo 'ID: ' . $id;
} else {
echo 'Status: ' . $status;
}
const response = await fetch('https://http-api.smsmanager.cz/Send', {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
body: new URLSearchParams({
apikey: 'your-api-key-here',
number: '420777123456',
text: 'Hello world!'
})
});
const responseText = await response.text();
const [status, id] = responseText.split('|');
if(status == "OK"){ // SMS was sent successfully
console.log('Status:', status);
console.log('ID:', id);
}
else{
console.log('Status:', status);
}
POST /api-send.php HTTP/1.1
Content-Type: application/x-www-form-urlencoded
Host: http-api.smsmanager.cz
apikey=your-api-key-here&to=420777123456&message=Hello%20world!