Detecting mobile phone with wurfl or mobiledetect.net not working on Galaxy S3

懵懂的女人 提交于 2019-12-25 03:21:04

问题


I have downloaded both wurfl api and mobiledetect.net and testing it with my Samsung Galaxy S3 (GT-19300).

I am very surprised that this smartphone is not detected with none of these script... There must be something wrong...

The script (http://www.gondwanastudio.com/xJava/WURFL/examples/demo/index.php) returns the following UA for the Galaxy S3... (User Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/11.0.696.34 Safari/534.24) and tells that " This is a Desktop Web Browser".

I have the same problem with the script (http://www.gondwanastudio.com/xJava/test.php) from mobiledetect.net.

include_once './inc/wurfl_config_standard.php';

$wurflInfo = $wurflManager->getWURFLInfo();

$requestingDevice = $wurflManager->getDeviceForUserAgent($_GET['ua']);

if ($requestingDevice->getCapability('is_tablet') == 'true') {
   echo "Tablet";
}

$is_wireless = ($requestingDevice->getCapability('is_wireless_device') == 'true');
$is_smarttv = ($requestingDevice->getCapability('is_smarttv') == 'true');
$is_tablet = ($requestingDevice->getCapability('is_tablet') == 'true');
$is_phone = ($requestingDevice->getCapability('can_assign_phone_number') == 'true');

if (!$is_wireless) {
 if ($is_smarttv) {
  echo "This is a Smart TV";
 } else {
  echo "This is a Desktop Web Browser";
 }
} else {
 if ($is_tablet) {
  echo "This is a Tablet";
 } else if ($is_phone) {
  echo "This is a Mobile Phone";
 } else {
  echo "This is a Mobile Device";
 }
}

回答1:


I think the issue is with your UA. Are you by chance using your phone in desktop mode? Right now it looks like it is identifying itself as desktop and not as mobile, which explains why it is not being detected. Your user agent should look more along the lines of:

Mozilla/5.0 (Linux; U; Android 4.0.4; en-us; GT-I9300 Build/IMM76K) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30

If you check using the WURFL tool on the ScientiaMobile site (http://tools.scientiamobile.com) , it should pull up as a Galaxy S3.



来源:https://stackoverflow.com/questions/20562595/detecting-mobile-phone-with-wurfl-or-mobiledetect-net-not-working-on-galaxy-s3

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!