2

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??

Ekky
  • 792
  • 4
  • 14
  • 29

2 Answers2

2

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.

Piran
  • 44
  • 1
  • Welcome to StackOverflow! It's quite ok to do self-promotion here. HOwever, if you are affiliated with this product, please make that clear in your answer, otherwise your post might end up being flagged as spam. – Alexis Pigeon Nov 22 '12 at 14:12
1

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.

SteveK
  • 996
  • 1
  • 8
  • 11