Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Schedule the sending of messages 1

Status
Not open for further replies.
Jul 28, 2011
167
NG
Hi all,

If you have ever been to a sms messaging site, you probably have seen that users can decide they want to schedule the sending of their sms message at a later time.
So a user logs on to the site (a real life example is at www.smslive247.com), composes the sms and clicks on "send message at a later time" radiobox. This gives users a datetime field that you can then pick what date and time you want the message to be dispatched (as well as ability to change the timezone).
Basically, users can schedule the sending of sms.

I'm also designing a similar site and wondering if anyone can tell me how this is done.

Thanks.

____________________
Men put up a strong face just to cover their weaknesses...good!
But a smile makes them live longer....
Which would you choose?

Think about it.
 
Store the send time in a database.
Create a script that retrieves all messages to be sent at or before the current time that have not been sent. Send those messages and mark them as sent in the database.
Create a from job to run that script every minute (or other interval)
 
that's iphones for you. always think they know better!

yes: from job == cron job ...

 
Thanks all,

I've reviewed all options over and over, but I dont seem to be getting the cron job idea.

@jpadie: Your idea seems interesting. Is there a way to create something like an sql server agent job (like in Microsoft SQL Server). Also, what kind of script are you talking about? Is it a php page or what? If the job can only be a cron job, can you explain step by step what needs to be installed on my server...please...

I'd really appreciate.

____________________
Men put up a strong face just to cover their weaknesses...good!
But a smile makes them live longer....
Which would you choose?

Think about it.
 
the step by step is in my first post.

something like this

Code:
[COLOR=#990000 ]<?php[/color]
[COLOR=#009900 ]$sql[/color] [COLOR=#990000 ]=[/color] [COLOR=#FF0000 ]"select * from messageList where messageSent = 0 and messageSendTime <= "[/color] [COLOR=#990000 ].[/color] [b][COLOR=#000000 ]time[/color][/b][COLOR=#990000 ]();[/color]
[COLOR=#009900 ]$result[/color] [COLOR=#990000 ]=[/color] [b][COLOR=#000000 ]mysql_query[/color][/b][COLOR=#990000 ]([/color][COLOR=#009900 ]$sql[/color][COLOR=#990000 ]);[/color]
[COLOR=#009900 ]$updated[/color] [COLOR=#990000 ]=[/color] [b][COLOR=#0000FF ]array[/color][/b][COLOR=#990000 ]();[/color]
[b][COLOR=#0000FF ]while[/color][/b] [COLOR=#990000 ]([/color][COLOR=#009900 ]$row[/color] [COLOR=#990000 ]=[/color] [b][COLOR=#000000 ]mysql_fetch_object[/color][/b][COLOR=#990000 ]([/color][COLOR=#009900 ]$result[/color][COLOR=#990000 ])):[/color]
  [COLOR=#009900 ]$sendResult[/color] [COLOR=#990000 ]=[/color] [b][COLOR=#000000 ]sendMessage[/color][/b][COLOR=#990000 ]([/color][COLOR=#009900 ]$row[/color][COLOR=#990000 ]);[/color]
  [b][COLOR=#0000FF ]if[/color][/b] [COLOR=#990000 ]([/color][COLOR=#009900 ]$sendResult[/color][COLOR=#990000 ]):[/color]
[tab] [COLOR=#009900 ]$updated[/color][COLOR=#990000 ][][/color] [COLOR=#990000 ]=[/color] [COLOR=#009900 ]$row[/color][COLOR=#990000 ][[/color][COLOR=#FF0000 ]'messageID'[/color][COLOR=#990000 ]];[/color]
  [b][COLOR=#0000FF ]endif[/color][/b][COLOR=#990000 ];[/color]
[b][COLOR=#0000FF ]endwhile[/color][/b][COLOR=#990000 ];[/color]

[i][COLOR=#9A1900 ]//update the database to mark messages as sent[/color][/i]
[COLOR=#009900 ]$sql[/color] [COLOR=#990000 ]=[/color] [COLOR=#FF0000 ]"updated messageList set messageSent = 1 where messageID in ( "[/color] [COLOR=#990000 ].[/color] [b][COLOR=#000000 ]implode[/color][/b][COLOR=#990000 ]([/color][COLOR=#FF0000 ]','[/color][COLOR=#990000 ],[/color] [COLOR=#009900 ]$updated[/color][COLOR=#990000 ])[/color] [COLOR=#990000 ].[/color] [COLOR=#FF0000 ]")"[/color][COLOR=#990000 ];[/color]
[COLOR=#009900 ]$result[/color] [COLOR=#990000 ]=[/color] [b][COLOR=#000000 ]mysql_query[/color][/b][COLOR=#990000 ]([/color][COLOR=#009900 ]$sql[/color][COLOR=#990000 ]);[/color]

[b][COLOR=#0000FF ]function[/color][/b] [b][COLOR=#000000 ]sendMessage[/color][/b][COLOR=#990000 ]([/color][COLOR=#009900 ]$data[/color][COLOR=#990000 ])[/color][COLOR=#FF0000 ]{[/color]
   [i][COLOR=#9A1900 ]// do something with the data.[/color][/i]
   [b][COLOR=#0000FF ]return[/color][/b] true[COLOR=#990000 ];[/color] [i][COLOR=#9A1900 ]//if the message was sent or false if not[/color][/i]
[COLOR=#FF0000 ]}[/color]

for setting cron jobs google [google]linux cron jobs[/google]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top