- Updating Device Data
- Useful Links
- Supported Versions
This tutorial illustrates the basic use of the 51Degrees API. It will show you how to create a provider, how to create a dataset and how to obtain a value for the IsMobile property.
Code and Explanation
Getting started example of using 51Degrees device detection. The example
shows how to:
my $filename = "51Degrees-LiteV3.2.dat";
my $propertyList = "IsMobile";
my $cacheSize = 10000;
my $poolSize = 20;
my $provider = new FiftyOneDegrees::PatternV3::Provider( $dataFile, $properties, $cacheSize, $poolSize);
my $match = $provider->getMatch($userAgent)
$match->getValue('IsMobile')This example assumes you are running from the original subdirectory i.e. Device-Detection/perl/examples/ and the 51Degrees Perl module is installed.
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 .