Pregunta

In my page I used a functionality of finding Geolocation of a given IP address. This returns result of particular location with zipcode.

But this zipcode is not accurate one. The difference of the zipcodes I got from coding and the real location is about more than 200 miles. I used the following code from ip2location website.

require_once('ip2location.class.php');

$ip = new ip2location;
$ip->open('./databases/IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-ISP-DOMAIN-NETSPEED-AREACODE-WEATHER-MOBILE-SAMPLE.BIN');

$record = $ip->getAll('50.178.183.243');

echo '<b>IP Address:</b> ' . $record->ipAddress . '<br>';
echo '<b>IP Number:</b> ' . $record->ipNumber . '<br>';
echo '<b>Country Short:</b> ' . $record->countryShort . '<br>';
echo '<b>Country Long:</b> ' . $record->countryLong . '<br>';
echo '<b>Region:</b> ' . $record->region . '<br>';
echo '<b>City:</b> ' . $record->city . '<br>';
echo '<b>ISP/Organisation:</b> ' . $record->isp . '<br>';
echo '<b>Latitude:</b> ' . $record->latitude . '<br>';
echo '<b>Longitude:</b> ' . $record->longitude . '<br>';
echo '<b>Domain:</b> ' . $record->domain . '<br>';
echo '<b>ZIP Code:</b> ' . $record->zipCode . '<br>';
echo '<b>Time Zone:</b> ' . $record->timeZone . '<br>';
echo '<b>Net Speed:</b> ' . $record->netSpeed . '<br>';
echo '<b>IDD Code:</b> ' . $record->iddCode . '<br>';
echo '<b>Area Code:</b> ' . $record->areaCode . '<br>';
echo '<b>Weather Station Code:</b> ' . $record->weatherStationCode . '<br>';
echo '<b>Weather Station Name:</b> ' . $record->areaCode . '<br>';
echo '<b>MCC:</b> ' . $record->mcc . '<br>';
echo '<b>MNC:</b> ' . $record->mnc . '<br>';
echo '<b>Mobile Brand:</b> ' . $record->mobileBrand . '<br>';
?>

I tried the coding in so many websites such as

But I didn't get the actual result. Accurate zipcode is not found in the above websites for the give IP address. Anybody can help me to solve this issue. Thanks for reading and solve this issue in advance.

¿Fue útil?

Solución

This is hazy by design, and it's nothing you can easily fix. IP-based geolocation services can only use the position information they guess from the various points from their server to the target IP. (You can see those points when you do a traceroute <targetip> on your console). How exact IP geolocation is depends on your user's ISP's architecture, and results can be way off in some areas, but pretty exact in others (especially cities).

If you seriously need exact geolocation, use client-side HTML 5 geolocation. This requires the user's consent, though, and can be imprecise as well if the client device doesn't have a GPS.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top