duanhao1004 2013-03-11 12:28
浏览 42
已采纳

查找50英里内给定IP地址的准确位置

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.

  • 写回答

1条回答 默认 最新

  • dtkago3208 2013-03-11 12:34
    关注

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用
  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?