Find out the user's city by ip
How to determine which city a site user is located in using php
or js
(html5 geolocation
do not offer!).
You need to know the city, knowing only ip
the user, and also so that you can use it for COMMERCIAL purposes and the city name is displayed in RUSSIAN letters (because there are many services, but they have the names of cities displayed in English).
0
2 answers
//Можно через curl
$request = file_get_contents("http://api.sypexgeo.net/json/".$_SERVER['REMOTE_ADDR']);
$array = json_decode($request);
echo $array->city->name_ru;
There are a lot of scripts and services on the Internet if you don't like this one, you can find another one
1
Author: alex159, 2017-09-01 18:35:41
Another service https://location.ekolesnyk.com
$url = 'https://location.ekolesnyk.com/api/v1/country/?apiKey={apiKey}&ip=www.google.com';
$response = file_get_contents($url);
$json = json_decode($response, true);
if((isset($json['error']))){
return $json['error']; //message error
}
return $json;
0
Author: Евгений Колесник, 2018-08-30 20:59:04