如何从IP地址确定邮政编码和城市? [英] How to determine a zip code and city from an IP address?

查看:120
本文介绍了如何从IP地址确定邮政编码和城市?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找有关开放式API或3D派对产品的建议,这将有助于将IP地址转换为邮政编码和城市,以制作特定于地理位置的网站内容。

解决方案

我使用的是ip2nation: http://www.ip2nation.com



这是一个完全免费的国家映射IP数据库。他们在他们的网站上包含了一些PHP示例脚本。



我在我的WordPress博客上使用它以及Ozh的免费 IP to Nation WordPress插件

即使你不是使用WordPress,下载插件,因为它会给你一个很好的PHP代码访问数据库。他甚至还有一个很好的小国家国旗,你可以在旁边显示,或者不用国家名称,这就是我自己显示标志的位置,可以在博客的评论者名字旁边显示。



真的,你不需要这个API。所有你需要的是数据库和能够编写PHP和SQL代码来访问它。



我不推荐ip2location用于临时使用。他们为他们的数据库收取很多费用,他们的数据库非常大,并且比大多数人需要更多的细节。



但ip2nation只能进入国家级别。如果您确实需要Cities和Zipcodes(尽管事实上它们可能是错误的,但其他答案/评论已经声明),那么除了ip2location之外,你可以试试GeoBytes 。它们具有特别适用于特定于地理位置的网站内容的组件,如GeoSelect: http://www.geobytes。 com / GeoSelect.htm



另外在Google上搜索ip to zipcode

I am looking for advice for open API or 3d party products which will help to convert an IP address to a zip code and city, to make geo-specific web site content.

解决方案

What I use is ip2nation: http://www.ip2nation.com

It is a completely free MySQL database of IP to country mappings. They include a few sample PHP scripts at their site.

I use it on my WordPress blog along with Ozh's free IP to Nation WordPress Plugin

Even if you are not using WordPress, download the plugin as it will give you a good set of PHP code to access the database with. He even has a nice set of tiny country flags that you can display next to, or instead of the country name, which is what I do to automatically show flags next my blog's commenter's names.

Really, you don't need an API for this. All you need is the database and an ability to write the PHP and SQL code to access it.

I wouldn't recommend ip2location for casual use. They charge a lot for their databases, and their databases are very large, and have more detail than most people need.

But ip2nation only goes to the Country level. If you do need Cities and Zipcodes (despite the fact that they can be wrong as other answers/comments have stated), then in addition to ip2location, you can try GeoBytes. They have components specifically suited for geo-specific web site content, such as GeoSelect: http://www.geobytes.com/GeoSelect.htm

Also search for "ip to zipcode" on Google.

这篇关于如何从IP地址确定邮政编码和城市?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆