如何在全球范围内使用带有API或Web服务和PHP的邮政编码或邮政编码来查找城市和州? [英] How can I look up City and State using Zip or Postal Code throughout the world using an API or web service with PHP?

查看:101
本文介绍了如何在全球范围内使用带有API或Web服务和PHP的邮政编码或邮政编码来查找城市和州?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用API​​或Web服务和PHP在全世界的邮政编码中查找城市和州?我尝试了Google Maps Ge编码器API,该API在美国和加拿大均能正常运行,但在所有国家/地区都无法在英国和墨西哥使用.我还为此使用了Yahoo API,它比Google更好用,但是针对某些邮政编码和邮政编码,它返回来自不同国家的结果.

How can I look up City and State From a Zip or Postal Code throughout the world using an API or web service with PHP? I have tried Google Maps Ge coder API, which works fine for US and Canada but not for UK and Mexico for all countries. Also I used Yahoo API for this, which worked better than Google but against some Zip Codes and Postal codes it returns results from Different countries.

如果我必须根据美国,英国,加拿大和墨西哥的邮政编码来获得城市和州/省的信息,有人知道我可以使用哪个API或数据库吗?

Does anybody know which API or database I can use if I have to get City and State/Province against US, UK, Canada and Mexican zip/postal codes?

推荐答案

好吧,不是很确定这是您要寻找的东西,但是我正在做类似的事情.我一直在使用以下免费Web服务.用户输入要在网络服务呼叫中使用的国家和邮政编码.

Well, not exactly sure this is what your looking for but I am working on something similar. I have been using the following free web services. User enters a country and Postal Code to be used in the web service calls.

文档: www.geonames.org/export/web-services.html

Documentation: www.geonames.org/export/web-services.html

用户需要输入国家和邮政编码.获取国家列表: http://api.geonames.org/countryInfo?username=demo **注册并用您的注册ID替换演示.

User needs to enter a country and Postal code. To get the list of countries: http://api.geonames.org/countryInfo?username=demo ** Register and replace demo with your registration id.

使用从以上服务中选择的国家代码和邮政编码,致电: http://api.geonames.org/postalCodeLookupJSON?postalcode=23454& ; country = US& username = demo

Using the country code selected from above service and the postal code, call: http://api.geonames.org/postalCodeLookupJSON?postalcode=23454&country=US&username=demo

希望这会有所帮助.

这篇关于如何在全球范围内使用带有API或Web服务和PHP的邮政编码或邮政编码来查找城市和州?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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