Jump to content

Time based events in PHP


motasem13hamad
Go to solution Solved by Barand,

Recommended Posts

What is wrong with you? We've already told you how to do it. We've explained the exact steps. Yet you keep repeating the same sentences like a madman.

 

Did you see our replies? Did you understand them? If not, then ask, but don't just skip the answers and repeat your question. That doesn't get you anywhere.

 

Yes, I understand that you want to run a PHP script at user-defined points of time. I'm not stupid. To implement this, you tell the Windows Task Scheduler to run a certain PHP script every minute (or whatever time interval you find appropriate). This script checks if there are any user-defined actions to do at this point in time and executes them.

 

Let's say user A wants to send an SMS at 16:00 today (UTC), and user B wants to send an SMS at 18:30. Your server would do this:

...
11:11: call PHP script -> nothing to do
11:12: call PHP script -> nothing to do
11:13: call PHP script -> nothing to do
...
15:59: call PHP script -> nothing to do
16:00: call PHP script -> user A wants to send an SMS, do it
...
18:29: call PHP script -> nothing to do
18:30: call PHP script -> user B wants to send an SMS, do it
...

You get the idea?

Link to comment
Share on other sites

A bit harsh, Jacques.

 

You'd set up a single task in the windows task scheduler that runs every 5 minutes or so (I think 1 minute would be a bit much, but you can if you want). That executes a php script. There are lots of examples in google how to set this up.

 

When the php script is executed, it checks a database to see if there are any sms to send out for the last 5 minutes (or whatever you want). If there are any present, send the sms's.

 

You would create some form or something for your users to set a time to send a sms, along with the message, and that's what gets stored in the above mentioned database.

 

As far as API to be able to directly manage tasks in the windows task scheduler, you could probably do that using a COM extension, but that would be much more difficult than the above. It would just be a lot easier to just have 1 task that executes your php script every x minutes.

Edited by CroNiX
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.