To download WURFL for PHP simply go to http://wurfl.sourceforge.net/php/index.php . Select the latest stable version. Once downloaded, simply unpack it into a web accessible folder (if you plan to make this detection available for public) or just put it into a internal folder and using command line PHP to access it.
Edit the wurfl_config.php file if necessary. In my installation, I edit the DATADIR directive to "/opt/www/html/wurfl/data/" instead of relative path "../data/". Make sure set permission on the folder to public writeable. For linux user, I recommend "chmod /opt/www/html/wurfl/data/ 666". For Windows user (with folder security and permission set on, right click -> Properties -> Security). For initial folder content, download the WURFL database file wurfl.xml and save into the data dir.
Once saved, you can test the installation by accessing check_wurfl.php with full URL. There's text box for you to input the user agent manually. But on the real working environment, you maybe need to pass user's UA string from http header value $_SERVER['HTTP_USER_AGENT'] to the application. In my case, you can use PHP CURL function on wap site side and return the user agent using var_export($wurflObj->capabilities). You can also convert the result using any array to xml converter to switch the result's format. My sample installation is available here.
Once you get the data, it's now all up to you how to provide the appropriate service based on these data. Happy wurfl-ing !!
1 comment:
very helpful article thanks.
Post a Comment