开发者

How do I validate country and state/province names and postal codes?

I am building an web app (with PHP) that requires users to subscribe. I would like for them to identify where they are from. So what is the b开发者_C百科est way to validate there country/state(or province)/city/postal code? Is there a DB with all the information? Which one is the best?


There are many options for address validation. The main issue is how much traffic your website will receive and whether or not you need support. If you are relatively small, you can get away with the free services like the following:

  • Google Maps API (example) (you may be breaking the TOS)
  • UPS Address Verification API (example)
  • USPS Address Web Tools

If you need something more robust or customizable, it will probably be necessary to pay for a service.


I know this is old, but to prevent others from going down the wrong path, the chosen answer to use Google API's may not have been aware of the google terms of service license (...the Geocoding API may only be used in conjunction with a Google map; geocoding results without displaying them on a map is prohibited.)

If you're not using a map...

and your requirements do not require commercial grade data, this sums up some options and what to look for.

however, if you need commercial data, greatdata.com and melissadata.com both sell real commercial level data products.

This thread is also helpful: stackoverflow thread on zip code data


Use the Google Geocoding API They allow 2,500 requests per day and you can pay for more. It will take an address and give you very detailed information on it and provide validation if you code it into your application.


Use the USPS Address Information API.


I've utilized data that can be purchased inexpensively from http://zipcodedownload.com/ to provide zip code validation/address correction in our applications.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜