- Updating Device Data
- Useful Links
- Supported Versions
This tutorial illustrates the basic use of the 51Degrees API using the Trie detection method. It will show you how to create a provider and how to obtain a value for the IsMobile property.
Code and Explanation
Set the various settings for 51Degrees detector
my $filename = "51Degrees-LiteV3.4.trie"; my $propertyList = "IsMobile"
Instantiate the 51Degrees device detection provider with these
my $provider = new FiftyOneDegrees::TrieV3::Provider( $dataFile, $properties);
Produce a match for a single HTTP User-Agent header
my $match = $provider->getMatch($userAgent)
Extract the value of the IsMobile property
In this tutorial you have seen how to use the detector to retrieve the IsMobile property for a pre-defined User-Agent string. The example can easily be modified to retrieve the value of any other property. Premium and Enterprise data files provide considerably more properties such as IsCrawler , PriceBand , HardwareVendor and ScreenInchesWidth . For a full list of properties and the data file versions they exist in please see the Property Dictionary .