A detailed description of all HTTP providers
- General
- Note about HTTP providers
- DeviceAtlasCom
- NeutrinoApiCom
- UdgerCom
- UserAgentApiCom
- UserAgentStringCom
- WhatIsMyBrowserCom
Regardless of which HTTP provider you use, you need always a valid client to connect.
This library uses the GuzzleHttp library.
use GuzzleHttp\Client;
use GuzzleHttp\HandlerStack;
use GuzzleHttp\Handler\CurlHandler;
$handler = new CurlHandler();
$stack = HandlerStack::create($handler);
$client = new Client([
'handler' => $stack,
'timeout' => 3,
'curl' => [
// CURLOPT_SSL_VERIFYHOST => false,
// CURLOPT_SSL_VERIFYPEER => false
]
]);In all following examples, we assume that you defined the $client already and it's working.
The client can throw additional Exceptions like timeout/no connection/... if something is not working well.
Also the API provider can have have issues.
Be aware that it can fail, when you use HTTP providers
Go to https://deviceatlas.com/ and get a valid API key.
use UserAgentParser\Provider;
// @see $client definition in chapter "General"
$deviceAtlas = new Provider\Http\DeviceAtlasCom($client, 'YOUR_API_KEY');
$result = $provider->parse($userAgent, $headers);Go to https://www.neutrinoapi.com/ and get a valid API key.
use UserAgentParser\Provider;
// @see $client definition in chapter "General"
$deviceAtlas = new Provider\Http\NeutrinoApiCom($client, 'YOUR_USER_ID', 'YOUR_API_KEY');
$result = $provider->parse($userAgent, $headers);Go to https://udger.com/ and get a valid API key.
use UserAgentParser\Provider;
// @see $client definition in chapter "General"
$deviceAtlas = new Provider\Http\UdgerCom($client, 'YOUR_API_KEY');
$result = $provider->parse($userAgent, $headers);Go to https://useragentapi.com/ and get a valid API key.
use UserAgentParser\Provider;
// @see $client definition in chapter "General"
$deviceAtlas = new Provider\Http\UserAgentApiCom($client, 'YOUR_API_KEY');
$result = $provider->parse($userAgent, $headers);Nothing to do, just use it
use UserAgentParser\Provider;
// @see $client definition in chapter "General"
$deviceAtlas = new Provider\Http\UserAgentStringCom($client);
$result = $provider->parse($userAgent, $headers);Go to https://www.whatismybrowser.com/ and get a valid API key.
use UserAgentParser\Provider;
// @see $client definition in chapter "General"
$deviceAtlas = new Provider\Http\WhatIsMyBrowserCom($client, 'YOUR_API_KEY');
$result = $provider->parse($userAgent, $headers);