-2

I have a bit of a problem, I have created the function below:

function sendQuedMessagesByDeviceAndDate($deviceId){
    require_once 'php/classes/smsGateway.php';
    $smsGateway = new SmsGateway(SMS_GATEWAY_EMAIL, SMS_GATEWAY_PASSWORD);
    $result = $smsGateway->getQuedMessages($deviceId);
    $arr = $result['response']['result'];
    $data = array();
    $options = [
        'expires_at' => strtotime('+24 hours') // Cancel the message in 24 hours if the message is not yet sent
    ];
    foreach($arr as $res){
        if($res['status'] == 'queued' && $res['device_id'] == $deviceId && $res['queued_at'] > 1475452800 && $res['queued_at'] < 1475539200){
            array_push($data, $res);
        }
    }
    //$nrs = array();
    foreach($data as $mes){
       $smsGateway->sendMessageToNumber($mes['contact']['number'], $mes['message'], $deviceId, $options);
    }
    //return $data;
}

and I have called that function 5-6 times by mistake, how can I tell the server from smsgateway to stop sending messages, I can't find any api call to stop the messages, and the email from their website is wrong, I can't send them any emails, and I don't have any international calling phone.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
CoAmA
  • 1
  • 4

2 Answers2

0

I hate to say this, but you're screwed. If the provider is not providing a way to clear the queue, they will be sent.

Next time, test more carefully by first replacing the sending-bit of the code with an echo statement. Just think what would happen if you've created an infinite loop by mistake...

L00_Cyph3r
  • 669
  • 4
  • 18
0

I have found that if you delete the device, it also deletes the queued messages of that device

CoAmA
  • 1
  • 4