Net-WURFL-ScientiaMobile
view release on metacpan or search on metacpan
lib/Net/WURFL/ScientiaMobile.pm view on Meta::CPAN
use Net::WURFL::ScientiaMobile;
my $scientiamobile = Net::WURFL::ScientiaMobile->new(
api_key => '...',
);
# process this HTTP request
$scientiamobile->detectDevice($env);
# check if the device is mobile
if ($scientiamobile->getDeviceCapability('ux_full_desktop')) {
print "This is a desktop browser.";
}
=head1 DESCRIPTION
The WURFL Cloud Service by ScientiaMobile, Inc. is a cloud-based
mobile device detection service that can quickly and accurately
detect over 500 capabilities of visiting devices. It can differentiate
between portable mobile devices, desktop devices, SmartTVs and any
other types of devices that have a web browser.
This is the Perl Client for accessing the WURFL Cloud Service, and
it requires a free or paid WURFL Cloud account from ScientiaMobile:
L<http://www.scientiamobile.com/cloud>
This module analyzes the C<$env> data structure of your incoming HTTP request and extracts
the device identifier string(s). It then queries the WURFL Cloud Service or the local cache
(if any is configured) to get the device capabilities.
lib/Net/WURFL/ScientiaMobile.pm view on Meta::CPAN
# nickname => [ host => weight ],
'wurfl_cloud' => [ 'api.wurflcloud.com' => 80 ],
},
);
=head1 METHODS FOR CAPABILITY DETECTION
=head2 detectDevice
$scientiamobile->detectDevice($env);
$scientiamobile->detectDevice($env, ['ux_full_desktop', 'brand_name']);
Get the requested capabilities from the WURFL Cloud for the given HTTP Request. If the second
argument is not provided, all available capabilities will be fetched.
Refer to the documentation of your web framework to learn how to access C<$env>. For example,
L<Catalyst> provides it in C<$ctx-E<gt>request-E<gt>env>, L<Dancer> provides it in
C<request-E<gt>env>, L<Mojo> provides it in C<$self-E<gt>tx-E<gt>req-E<gt>env>.
Instead of the C<$env> hashref you can also supply a L<HTTP::Headers> or a L<Mojo::Headers> object.
This is handy when you're not running in a PSGI environment and your web server doesn't supply
( run in 0.402 second using v1.01-cache-2.11-cpan-299005ec8e3 )