|go ahead... be a heretic|
Get Out of a Dull Meetingby hardburn (Abbot)
|on Nov 30, 2004 at 20:43 UTC||Need Help??|
You're sitting at a table with your cow-orkers while the head beancounter goes through his drone about how the bar on the chart for last quater is clearly larger than the bar for the quarter before, and you're starting to wonder if you can slip a certain almond-tasting chemical into the beancounter's coffee.
No worry. You covertly slip your 802.11-enabled PDA out of your pocket and browse to your web server, where you've kept the CGI below for this very situation. Not long after, you receive an SMS on your cell telling you about some emergency or other. You glance at your phone, bolt out of the room, and take an early lunch.
This CGI is for use under mod_perl2, but it shouldn't be hard to modify for regular CGI use.
The send_sms() routine gets a string containing the message to send, and returns true on success, false on failure. It's coded to use Sprint's web form for sending the message. You'll have to change it for your provider. See also: WWW::SMS.
The constant MESSAGES is an arrayref containing the messages to send. Be sure they are <= 160 chars (SMS limit). You can set which message to send with the 'emg' parameter ("emg=0" is the first message, "emg=1" is the second, etc.). The first message is used by default.
You'll need to replace the TO and FROM constants with your phone number.
Update: Added ikegami's change to make sure send_sms() never gets a message over 160 chars.
Update (2): Added readmore tags.
"There is no shame in being self-taught, only in not trying to learn in the first place." -- Atrus, Myst: The Book of D'ni.