PHP code example of yandex / locator
1. Go to this page and download the library: Download yandex/locator 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 / locator example snippets
// использовать встроенный автозагрузчик, либо через composer
� IP
$api->setIp('88.88.88.88');
try {
$api->load();
} catch (\Yandex\Locator\Exception\CurlError $ex) {
// ошибка curl
} catch (\Yandex\Locator\Exception\ServerError $ex) {
// ошибка Яндекса
} catch (\Yandex\Locator\Exception $ex) {
// какая-то другая ошибка (запроса, например)
}
$response = $api->getResponse();
// как определено положение
$response->getType();
// широта
$response->getLatitude();
// долгота
$response->getLongitude();
// сериализация/десереализация объекта
var_dump(unserialize(serialize($response)));