Iam very happy to use WURFL. My use of wurfl is to detect Mobile Brand,Model,OS and Resolution to list mobile application in our site.
But the problem is in some browsers like opera mini,google chrome (Mobile browsers) i can't get correct device details.
My code :
Code: Select all
<html>
<head>
<title>WURFL PHP API Example</title>
</head>
<body>
<?php
// Include the configuration file
include_once './inc/wurfl_config_standard.php';
$wurflInfo = $wurflManager->getWURFLInfo();
if (isset($_GET['ua']) && trim($_GET['ua'])) {
$ua = $_GET['ua'];
$requestingDevice = $wurflManager->getDeviceForUserAgent($_GET['ua']);
} else {
$ua = $_SERVER['HTTP_USER_AGENT'];
// This line detects the visiting device by looking at its HTTP Request ($_SERVER)
$requestingDevice = $wurflManager->getDeviceForHttpRequest($_SERVER);
}
?>
<h3>WURFL XML INFO</h3>
<ul>
<li><h4>VERSION: <?php echo $wurflInfo->version; ?> </h4></li>
</ul>
<div id="content">
User Agent: <b> <?php echo htmlspecialchars($ua); ?> </b>
<ul>
<li>ID: <?php echo $requestingDevice->id; ?> </li>
<li>Brand Name: <?php echo $requestingDevice->getCapability('brand_name'); ?> </li>
<li>Model Name: <?php echo $requestingDevice->getCapability('model_name'); ?> </li>
<li>Marketing Name: <?php echo $requestingDevice->getCapability('marketing_name'); ?> </li>
<li>Preferred Markup: <?php echo $requestingDevice->getCapability('preferred_markup'); ?> </li>
<li>Resolution Width: <?php echo $requestingDevice->getCapability('resolution_width'); ?> </li>
<li>Resolution Height: <?php echo $requestingDevice->getCapability('resolution_height'); ?> </li>
</ul>
<p><b>Query WURFL by providing the user agent:</b></p>
<form method="get" action="index.php">
<div>User Agent: <input type="text" name="ua" size="100" value="<?php echo isset($_GET['ua'])? htmlspecialchars($_GET['ua']): ''; ?>" />
<input type="submit" /></div>
</form>
</div>
</body>
</html>
Output From Samsung Galaxy S2 - Using Google Chrome Browser
Code: Select all
URFL XML INFO
VERSION: For distribution with API 1.4, db.scientiamobile.com - 2012-03-26 09:10:51
User Agent: Mozilla/5.0 (Linux; Android 4.1.2; GT-I9100 Build/JZO54K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.72 Mobile Safari/537.36
ID: generic_web_browser
Brand Name: generic web browser
Model Name:
Marketing Name:
Preferred Markup: html_web_4_0
Resolution Width: 800
Resolution Height: 600
Query WURFL by providing the user agent:
Output From Samsung Galaxy S2 - Using Default Browser
Code: Select all
VERSION: For distribution with API 1.4, db.scientiamobile.com - 2012-03-26 09:10:51
User Agent: Mozilla/5.0 (Linux; U; Android 4.1.2; en-us; GT-I9100 Build/JZO54K) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30
ID : generic_android_ver4_1
Brand Name: Generic
Model Name: Android 4.1
Marketing Name:Preferred
Markup: html_web_4_0
Resolution Width: 320
Resolution Height: 480
Thanks