How to send Multiple sms in one php script using EnvayaSMS

64 views
Skip to first unread message

Olana Kenea

unread,
Jun 23, 2018, 8:11:13 AM6/23/18
to envayasms
i am trying to send multiple sms from my php script ot diffrent reciepent but i am unable to do it it only send for the first number in the loop ...please help i have attached my  code
save_attendance.php

Илья Ермушко

unread,
Jul 27, 2018, 10:53:27 AM7/27/18
to envayasms
hi, i do it that way:

case EnvayaSMS::ACTION_OUTGOING:
$actual_messages = $db->getAll('SELECT id, number "to", message, NOW() now_datetime,
       created created_datetime,
       ( created + INTERVAL send_delay MINUTE ) send_start_datetime,
       ( created + INTERVAL expiry_delay MINUTE
         + INTERVAL send_delay MINUTE )         send_end_datetime
FROM   sms_gate
WHERE  NOW() >= ( created + INTERVAL send_delay MINUTE )
       AND NOW() <= ( created + INTERVAL expiry_delay MINUTE + INTERVAL send_delay MINUTE )
       AND (status = 0  OR status = 2)
       AND LENGTH(number) = 11
ORDER  BY status ASC, id ASC
LIMIT  1');
$messages = [];
foreach ($actual_messages as $message) {
$sms = new EnvayaSMS_OutgoingMessage();
$sms->id = $message['id'];
$sms->to = $message['to'];
$sms->message = $message['message'];
$sms->priority = NULL;
$sms->type = NULL;
$messages[] = $sms;
}
$events = [];
if ($messages) {
$events[] = new EnvayaSMS_Event_Send($messages);
}
echo $request->render_response($events);
return;

LIMIT 1 is suitable for 12 messages in minute / 720 in a hour with 5 sec poll delay. But you can delete LIMIT at all and send all of them as an array.

hope that helps!

суббота, 23 июня 2018 г., 19:11:13 UTC+7 пользователь Olana Kenea написал:
Reply all
Reply to author
Forward
0 new messages