Appendix A. Detecting Browsers with WURFL

WURFL (Wireless Universal Resource File) is an XML file that contains the information needed to identify a wide range of mobile devices. On its own, it doesn’t do anything. But if you use one of the many available libraries for it, you can create web apps that can figure out what kind of device has connected to your app.

For example, wurfl-php (http://sourceforge.net/projects/wurfl/files/WURFL%20PHP/) lets you detect which operating system a remote device is running from within a PHP script.

Note

To use WURFL and wurfl-php, you’ll need to be running your web app on a hosting provider that supports PHP. You’ll also need to understand how to install files and PHP libraries onto your server. In this appendix, I show you how to do this using the Unix or Mac OS X command line. If you are uncomfortable with any of this, but are comfortable working with PHP, contact your hosting provider’s support department and ask if they’d be willing to install WURFL and wurfl-php on the server you use. If you’re using a shared server, it would give your hosting provider a competitive advantage to offer this feature to all their customers.

Installation

First, download wurfl-php and unzip it somewhere on your server (in general, it’s best to not put libraries in your public web folder, so I’m putting it into the src directory in my home directory). Replace ~/src with the location you want to install it to and replace wurfl-php-1.1.tar.gz with the name of the file ...

Get Building Android Apps with HTML, CSS, and JavaScript now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.