如何在全球范围内使用带有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?
问题描述
如何使用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屋!