Php – How to look up City and State using Zip or Postal Code throughout the world using an API or web service with PHP

google mapsPHPyahoo-maps

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.

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?

Best Answer

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.

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

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.

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

Hope this helps.

Related Topic