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://wurfl.sourceforge.net/nphp/) 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 extract 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.3.1.tar.gz
with the name of the file ...
Get Building Android Apps with HTML, CSS, and JavaScript, 2nd Edition 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.