PHP code example of yandex / detector
1. Go to this page and download the library: Download yandex/detector library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
yandex / detector example snippets
$api = new \Yandex\Detector\Api();
try {
// Взять параметры из заголовков, переданных серверу
$api->load();
// Или указать параметры вручную
$api
->reset()
->setUserAgent('Alcatel-CTH3/1.0 UP.Browser/6.2.ALCATEL MMP/1.0')
->setWapProfile('http://www-ccpp-mpd.alcatel.com/files/ALCATEL-CTH3_MMS10_1.0.rdf')
->load();
} catch (\Yandex\Detector\Exception $ex) {
}
$response = $api->getResponse();
if (!$response) {
echo 'Телефон не определен';
} else {
echo $response->getName();
echo $response->getVendor();
if ($response->isIphone()) {
} elseif ($response->isAndroid()) {
}
echo $response->getScreenWidth() . 'x' . $response->getScreenHeight();
}
$api = new \Yandex\Detector\Api(array(CURLOPT_CONNECTTIMEOUT => 20, CURLOPT_TIMEOUT => 30));
// ...