In my PHP Script i have used Tera-WURFL api to get the Screen resolution of mobile Handset but the result i am getting is not correct... here is a code ...

**<?php
require_once('Tera-Wurfl/TeraWurfl.php');

$wurflObj = new TeraWurfl(); 

$wurflObj->getDeviceCapabilitiesFromAgent();

echo "Markup: ".$wurflObj->getDeviceCapability("preferred_markup");

// see the display resolution
$width = $wurflObj->getDeviceCapability("resolution_width");
$height = $wurflObj->getDeviceCapability("resolution_height");
echo $_SERVER['HTTP_USER_AGENT'];
echo "<br/>Resolution: $width x $height<br/>";
?>**

What i have done wrong here??

有帮助吗?

解决方案

You can download and use free 51Degrees.mobi Lite data and documentation from: http://sourceforge.net/projects/fiftyone/?source=directory

You can use 51Degrees.mobi properties using the following code:

 <?php
require_once('51Degrees.mobi.php');

$ScreenPixelsHeight = $_51d["ScreenPixelsHeight"];
$ScreenPixelsWidth = $_51d["ScreenPixelsWidth"];

?>

Note: All the data stored in the $_51d array is stored as strings, you may have to convert $ScreenPixelsHeight and $ScreenPixelsWidth into a number.

其他提示

You are using the library correctly. The problem is probably related to the user agent of the device that your're testing with. If, for example, you are testing with a desktop web browser, it is impossible to tell what the resolution is, since this information is not conveyed in the user agent, and cannot be inferred.

Please note that I am the author of Tera-WURFL.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top