使用wurfl或mobiledetect.net检测手机在Galaxy S3上不工作


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

我已经下载了wurfl-api和mobiledetect.net,并用我的三星Galaxy S3(GT-19300)进行了测试。

我很惊讶,这款智能手机没有检测到这些脚本。。。一定是出了什么问题。。。

脚本(http://www.gondwanastudio.com/xJava/WURFL/examples/demo/index.php)返回Galaxy S3的以下UA…(用户代理:Mozilla/5.0(X11;Linux x86_64)AppleWebKit/534.24(KHTML,类似Gecko)Chrome/11.0.696.34 Safari/534.24),然后告诉"这是一个桌面Web浏览器"。

我对剧本也有同样的问题(http://www.gondwanastudio.com/xJava/test.php)来自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";
 }
}

我认为问题出在你的UA上。你在桌面模式下偶然使用手机吗?现在,它似乎将自己识别为台式机,而不是移动设备,这解释了为什么它没有被检测到。您的用户代理应该更多地关注以下方面:

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

如果您使用ScientiaMobile网站上的WURFL工具进行检查(http://tools.scientiamobile.com),它应该是Galaxy S3。