Přeskočit na hlavní obsah

Příklad odeslání SMS zprávy

Odeslání SMS zprávy

<?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;
}