Posted by txetxuda 1 year 50 weeks ago
Hi,
I'm having a problem with device atlas which is detecting IE7 running on a PC as a mobile device. Is this the normal behaviour? I have no problems with the rest of browsers
I'm using PHP with Mobi_Mtld_DA_Api::getProperties($tree, $_SERVER['HTTP_USER_AGENT']).
Thanks in advance
Aleix Vergés




Posted by daniel.hunt 1 year ago
Mobile Grandmaster
Can you copy/paste the UserAgent being detected incorrectly here please?
Daniel HuntIf you don't know how to find it, go to http://logme.mobi/ and paste the page you see here.
dotMobi
Posted by txetxuda 1 year ago
Hi,
This is the response:
See your exact HTTP request headers:
Accept=image/gif, image/jpeg, image/pjpeg, image/pjpeg, application/xaml+xml, application/vnd.ms-xpsdocument, application/x-ms-xbap, application/x-ms-application, application/x-silverlight, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, application/x-shockwave-flash, */*
Accept-Language=es,ca-ES;q=0.5
User-Agent=Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; InfoPath.1; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)
Accept-Encoding=gzip, deflate
Host=logme.mobi
Connection=Keep-Alive
And my code:
class Zebra_Controller_Plugin_DeviceSelector extends Zend_Controller_Plugin_Abstract
{
public function preDispatch(Zend_Controller_Request_Abstract $request)
{
$memcache_enabled = extension_loaded("memcache");
$no_cache = array_key_exists("nocache", $_GET);
if ($memcache_enabled && !$no_cache) {
$memcache = new Memcache;
$memcache->connect('localhost', 11211);
$tree = $memcache->get('tree');
}
if (!isset($tree) || !is_array($tree)) {
$tree = Mobi_Mtld_DA_Api::getTreeFromFile(APP_ROOT."/data/mobile/Sample.json");
if ($memcache_enabled && !$no_cache) {
$memcache->set('tree', $tree, false, 10);
}
}
if ($memcache_enabled && !$no_cache) {
$memcache->close();
}
$properties = Mobi_Mtld_DA_Api::getProperties($tree, $_SERVER['HTTP_USER_AGENT']);
//further performance can be gained through caching the properties against the user-agent as a key (since many requests are likely to come from one device during its visit)
if(isset($properties['mobileDevice']) && $properties['mobileDevice']== 1){
$deviceProperties = array();
$deviceProperties['displayWidth'] = $properties['displayWidth'];
$deviceProperties['displayHeight'] = $properties['displayHeight'];
$deviceProperties['displayColorDepth'] = $properties['displayColorDepth'];
$deviceProperties['vendor'] = $properties['vendor'];
$deviceProperties['model'] = $properties['model'];
$deviceProperties['model'] = $properties['model'];
$deviceProperties['mobileDevice'] = $properties['mobileDevice'];
} else {
$deviceProperties['mobileDevice'] = false;
}
Zend_Registry::set('DeviceProperties', $deviceProperties);
}
}
Thank you so much,
Aleix Vergés
Posted by daniel.hunt 1 year ago
Mobile Grandmaster
Ah, I see the problem now.
The UserAgent you're using is being recognised by DeviceAtlas correctly, but unfortunately you're using the *SAMPLE* json file, distributed with the API to get you up and running quickly!
That file is very old (with good reason), so you should register for a (free) Evaluation licence on http://deviceatlas.com to continue with your development, and then when you go to deploy to a live server you can upgrade that licence to a paid one!
Daniel HuntdotMobi
Posted by txetxuda 1 year ago
Hi,
Thanks a lot! Updating the sample JSON file solved the issue.
Regards
ALeix Vergés
Posted by daniel.hunt 1 year ago
Mobile Grandmaster
Happy to help :)
Daniel HuntdotMobi