PHP Classes

PHP USPS API Zip Code: Get the zip code of a given location with USPS API

Recommend this page to a friend!
  Info   Documentation   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 120 All time: 9,503 This week: 524Up
Version License PHP version Categories
usps-zipcode 2GNU General Publi...7.4PHP 5, E-Commerce, Web services
Description 

Author

This package is specific mainly for applications used in United States United States .

This class can get the zip code of a given location with USPS API.

It can send a HTTP request to the USPS API Web server to request the zip code for a given physical address in the United States.

The class can parse the response and return the zip code that was found for that address.

Version 2.0 of this package increases the minimum required PHP version to 7.4. It is fully compliant without deprecated code in 8.2.

It supports USPS API v3 system.

Innovation Award
PHP Programming Innovation award nominee
January 2019
Number 4


Prize: One downloadable copy of PhpED Professional
Many applications that deal with addresses of people or companies need to know the addresses where they are located, so they can send them postal mail or parcels.

One of the details that is necessary to know about an address is the zip code.

This class can determine the zip code of a given location using the street address and city and the USPS API to find out the zip code of location in the United States.

Manuel Lemos
Picture of Jason Olson
  Performance   Level  
Name: Jason Olson is available for providing paid consulting. Contact Jason Olson .
Classes: 5 packages by
Country: United States United States
Age: ???
All time rank: 3202435 in United States United States
Week rank: 200 Up22 in United States United States Up
Innovation award
Innovation award
Nominee: 2x

Documentation

usps_address_validation

This CLASS is designed to take advantage of the USPS API for looking up the corrected (normalized) address for a given physical address. There is very little examples of implementing the USPS API in PHP.

Configuration

When you instantiate the class, include the API key. See the example.php file for usage. If you don't have a valid USPS.com API, you can get one free at https://www.usps.com/business/web-tools-apis/welcome.htm

Revision History:

  • 1.0 Initial Release
  • 1.1 Bugfix 500 error.
  • 2.0 Updated for new USPS API V3 & PHP 8 coding standards

This code was written by request by another developer on phpClasses.org because Streetlayers is going away very soon.

License

GNU General Public License v3.0 (GNU GPLv3) http://www.gnu.org/licenses/gpl-3.0-standalone.html


  Files folder image Files (4)  
File Role Description
Accessible without login Plain text file example.php Example Example script
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file README.md Doc. Documentation
Plain text file USPS.php Class Class source

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:120
This week:0
All time:9,503
This week:524Up