1

在我的页面中,我使用了查找给定 IP 地址的地理位置的功能。这将返回带有邮政编码的特定位置的结果。

但是这个邮政编码并不准确。我从编码中得到的邮政编码与实际位置的差异大约有 200 多英里。我使用了 ip2location 网站上的以下代码。

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>';
?>

我在很多网站上尝试过编码,例如

但是我没有得到实际的结果。在上述网站中未找到给定 IP 地址的准确邮政编码。任何人都可以帮助我解决这个问题。感谢您阅读并提前解决此问题。

4

1 回答 1

5

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.

于 2013-03-11T12:34:36.620 回答