Try this version. I was reading your details and this service does not allow more than one call per second and they do not allow sending the same message to large number of phones. Therefore, you might need to add some sort of reference number inside the message so that the message is different each time. Not sure at all on this…
<?php
if (isset($_POST["submit"])) {
// Open the text file. ( HERE YOU WOULD NEED TO CHANGE THE NAME OF THE FILE TO YOUR FILENAME ! ! ! )
$numbers_file = fopen("inputfile.txt", "r");
// Read one line at a time ( one phone number per line )
while (($phone_number = fgets($numbers_file)) !== false) {
// Process the one phone number, create the URL paramenters with info in the correct places
$url_parms = "?token=e9cf7e33-0c00-4eb5-94fb-7ae060fa4329&source=8445972807&destination=" . trim($phone_number) . "&message='This is The National Health Enrollment Center. You are still eligible to enroll in an affordable health insurance plan. Call 844-597-2807 now to speak with a licensed agent.'";
// Using the created URL, send it using Curl
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"https://sms.teleapi.net/sms/send");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $url_parms);
// Send message and receive server response ...
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
$response = json_decode($response);
if ($response->code == 200) {
echo "SMS sent out to: " . $trim($phone_number) . "<br>";
} else {
echo "ERROR sending SMS to: " . $trim($phone_number) . "<br>";
}
// To not cause issues with the server being overwhelmed, delay one second between SMS' . This might be able to be lowered.
sleep(1);
}
// Close the file
fclose($numbers_file);
}
?>
<!DOCTYPE html>
<html>
<body>
<h1>Send SMS messages to all numbers in text file</h1>
<input type="submit" name="submit" value="send_now" />
</body>
</html>
I changed the error reporting section and also added quotes on your message as I think that might be a problem. Good luck…