Testing wurflphp

Now, in your web directory (such as Sites or public_html), create the following PHP file (name it something like wurfl-test.php). The first time you visit it from your Android device (or any other browser), it will take a long time as it builds the initial cache. After that it should be zippy. Figure A-1 shows how this should appear in your browser. You can now modify this PHP code to suit your needs:

<meta name="viewport" content="user-scalable=no, width=device-width" /> <title>WURFL Test</title> <?php define("WURFL_DIR", "/Users/bjepson/src/wurfl-php-1.1/WURFL/"); define("RESOURCES_DIR", "/Users/bjepson/src/wurfl-php-1.1/");

require_once WURFL_DIR . 'Application.php';

$wurflConfigFile = RESOURCES_DIR . 'wurfl-config.xml'; $wurflConfig = new WURFL_Configuration_XmlConfig($wurflConfigFile); $wurflManagerFactory = new WURFL_WURFLManagerFactory($wurflConfig);

$wurflManager = $wurflManagerFactory->create(); $wurflInfo = $wurflManager->getWURFLInfo();

$requestingDevice = $wurflManager->getDeviceForHttpRequest($_SERVER); $is_android = FALSE;

if ($requestingDevice->getCapability("device_os") == "Android") { $is_android = TRUE;

</head> <body> <?php if ($is_android) { echo "I spy an Android phone.";

<ul> <?php foreach ($requestingDevice->getAllCapabilities() as $key => $value) { echo "<li>$key = $value";

I couldn't use so I had to put in the full path to the WURFL stuff; replace /Users/NAME/src/wurfl-php-1.1/ with the full path to the wurfl-' v ! $ php directory you created earlier.

ziffle 5:25pm

ü http://jepstoneJocal/~bj,.. P

I spy an Android phone.

• mobile_browser = Android Webkit

• has_qwerty_keyboard = true

• polntingjnethod = touchscreen

• mobile_browser_version =

• device_claims_web_support = true

• ununiqueness_handler =

• model extra info = Google Phone

Figure A-1. Output of the sample wurfl-php script

0 0

Post a comment