Search

Vote for the next Prime Minister by SMS - a PHP/MySQL teaching example.

I am intrigued by the possibility of low-tech mobile applications based on the ubiquitous SMS  (texting) protocol. In the BIT school we use a Clickatell service to provide both outbound and 2-way messaging.  Text messages originating from a mobile phone are routed through the mobile network to servers in South Africa,  from where the message is delivered by HTTP to an XQuery script on our server.  This script takes the first word of the message as the code word and via an XML routing table, calls the corresponding server script via HTTP, passing the code, the remaining text and the originating mobile number.  The application processes the message and returns an XML response, which in turn may be sent to the originating mobile phone if required. This provides an framework into which student applications, in any language, can be plugged.

As a demonstration of the ease of writing an SMS-based application in PHP/MySQL applications, I use a simple voting application.  We have run polls for several years with this software.  This year with a sad lack of imagination and total disregard for the non-presidential nature of our parliamentary system, I asked the question "Who should be the next Prime Minister?".  The results (and voting instructions should you care to participate) are on a web page.

Before voting, you should be aware of a fault in my implementation that struck me mid-sentence as I was explaining it to my students.  In order to prevent multiple voting from the same phone, I store the originating number in the database. Since I need only check for uniqueness and am not interested in the number itself (I swear I have no intention of selling the numbers on to the candidates), I should store a one-way hash of the number instead for greater privacy. I wonder how many SMS applications do this?