https://www.netgsm.com.tr/sms/toplu-sms Hocam buradan sms ücretlerini öğrenebilirsiniz.
Buda daha önce projelerimin arasında yer alan basit bir kod parçacığı
<?php
$apiUrl = "xxx";
$apiKey = "xxx";
$pdo = new PDO("mysql:host=localhost;dbname=xxx", "xxx", "xxx");
$sql = "SELECT tel FROM uyeler";
$stmt = $pdo->query($sql);
$phoneNumbers = [];
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
$phoneNumbers[] = $row['tel'];
}
$message = "Mesaj İçeriği";
$batchSize = 1000;
for ($i = 0; $i < count($phoneNumbers); $i += $batchSize) {
$batch = array_slice($phoneNumbers, $i, $batchSize);
$postData = [
'apiKey' => $apiKey,
'message' => $message,
'numbers' => implode(',', $batch)
];
$ch = curl_init($apiUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($postData));
$response = curl_exec($ch);
curl_close($ch);
if ($response) {
echo "Batch " . ($i / $batchSize + 1) . " başarıyla gönderildi.\n";
} else {
echo "Batch " . ($i / $batchSize + 1) . " gönderilirken hata oluştu.\n";
}
sleep(1);
}
?>