phpcurljobssms-gatewaybulksms

Best way to send multiple SMS at one click using SMS Gateway


I'm working on a PHP website where when user selects city and submits the form, it will get the users phone numbers from the database for that particular city and sends SMS to them.

I have used cURL functions within a while loop to execute this and it is working fine.

NOTE: My sms gateway provider's API only support one number at a time per http request.

Now my question is if the number of user in the selected city is more than 10000 or 50000, then using cURL method will take much time to execute since it's in the loop? But the user wont like wait for the completion of loop. Is there any better way than doing this, like when user submits the request, something in backend (like job) will execute the function and even if the user closes the page, that job will execute till it completes the loop.


Solution

  • my solution was this:

    --page /sendsms/?phone_nr=1122 sends one sms to phone nr 1122

    --page /sendbulk has a loop which calls in php the page /sendsms/?phone_nr=1122 with file function file('http://www.domain.com//sendsms/?phone_nr=' . $phone_nr[$i]);

    --the client on submit will call with ajax(no return needed) the page /sendbulk

    This way even if the client closes the connection the server will continue to run /sendbulk in background and will send all messages