Building Android Apps with HTML, CSS, and JavaScript, 2nd Edition
by Jonathan Stark, Brian Jepson, Brian MacDonald
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 you actually downloaded: ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access