Ever wonder what it took to get a site to work on those new "web-enabled" cell phones? This short tutorial will do just that by giving you the basics of making your site WAP-enabled using PHP.Reprinted from http://www.gbdirect.co.uk/ with permission.
After we got the HTML site going, the next task was to WAP it up. The first concern was how much we would have to hack php3 to tell it not to emit a first line that says
Content-type: text/html
Although I couldn't find it documented anywhere, I found to my deep and abiding joy that if you use the php3 header() function to output a different content-type header, that suppresses the default. Bingo! Every WML card deck now includes this php fragment at the top:
and that deals with all the usual crud you have to cough out
to get started with WAP. From there on it was plain sailing. It took six hours to a) learn enough WML to get something done and b) implement it. I used Steve Mann's book "Programming Applications with the Wireless Application Protocol" (Wiley, ISBN 0-471-32754-9) as my reference, plus a few downloaded tutorials from places like Waptastic for backup. I wouldn't recommend any of them. Considering how restricted the WML language is, you would have thought it wouldn't take much explaining, but I have yet to see a decent tutorial on it. Maybe I am just too dim to pick it up easily. That might also account for how limited our current WAP version of the site is.
Of course you can't rely on WML being correct without testing it. If there is a WML weblint-alike, I'd like to find it, but haven't looked hard enough yet. It would be a big help to ensure that the WML is well-formed on the way out. You also have to check that your WAP site `works', to the degree that you can make anything work through such a limited medium. There are a number of WAP phone simulators around. There is a web-based one at Gelon as well as others from phone.com and the marvellously named Slob-Trot in Finland. Sadly both the latter two only run under Windows so far as I can tell, but vmware came to the rescue. Or, at least it did for the Slob Trot browser, the phone.com version ran but didn't paint any images on the screen. I later found a native Windows machine and it seemed OK on that.
Using the simulators to test the WML allowed the php3 templates to be written very quickly. Here is the full `place' template: