创建WURFL补丁匹配部分用户代理 [英] Create WURFL patch matching partial user-agent
问题描述
我使用WURFL,以确定用户是否在移动设备上。一些用户代理字符串被错误地确认为这反过来导致内容类型被错误设置移动设备
I'm using WURFL to identify whether a user is on a mobile device. Some User-Agent strings are incorrectly recognized as mobile devices which in turn causes the content-type to be set incorrectly.
下面一个现实生活中的用户代理行为像这样的例子:
Here an example of a real life user agent behaving like this:
Mozilla/5.0 (GTmetrix http://gtmetrix.com/; X11; U; Linux i686 (x86_64); en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13
的内容类型,然后设置为应用程序/ vnd.wap.xhtml + XML
而不是的text / html
。
我想,以承认它是一个非移动浏览器添加到web_browsers_patch.xml文件中的条目。
I would like to add an entry to the web_browsers_patch.xml file in order to recognize it as a non mobile browser.
以下工作:
<device id="mozilla_ver5"
user_agent="Mozilla/5.0 (GTmetrix http://gtmetrix.com/; X11; U; Linux i686 (x86_64); en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13"
fall_back="generic_web_browser" />
然而,为了不必须添加所有可能的用户代理的变化,我想部分匹配。是这样的:
However, in order to no have to add all possible user agent variations, I would like to match it partially. Something like:
<device id="mozilla_ver5"
user_agent="Mozilla/5.0 (GTmetrix"
fall_back="generic_web_browser" />
不幸的是,这并不工作 - 网页的内容类型重新设置不正确
Unfortunately, this does not work - the content type of the page is again set incorrectly.
的是否有可能增加一个WURFL补丁匹配部分用户代理字符串?怎么样?的
(相关奖金的问题:我如何确定哪个配置文件的用户代理字符串被匹配)
(Related bonus question: How can I determine to which profile a user agent string was matched?)
我使用 HTTP提供的51Degrees基础API://51degrees.$c$cplex.com /
推荐答案
如果您使用的是51Degrees,你可以拆开一些它返回的对象。下面一起来看看: http://51degrees.mobi/Support/Documentation/Foundation/WURFLMappingTable。 ASPX
If you are using 51Degrees, you can take apart some of the objects it returns. Take a look here : http://51degrees.mobi/Support/Documentation/Foundation/WURFLMappingTable.aspx
这应该让你的USER_AGENT和其他属性的一群,以满足您的需求。
This should get you the user_agent and a bevy of other properties to suit your needs.
这篇关于创建WURFL补丁匹配部分用户代理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!