File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ # USPS Address Validator v2 Changelog
2+
3+ ## New Features
4+
5+ * Updated to use the very latest API v3 from USPS
6+
7+ ## Breaking changes
8+
9+ * The minimum required PHP version changed from PHP 5 to PHP 7.4
10+
11+ ## Thanks
12+ To contributors, be it with PRs, reporting issues or supporting otherwise.
13+
Original file line number Diff line number Diff line change 1+ {
2+ "name" : " reddingwebdev/usps_zip_code" ,
3+ "description" : " This class will take a normalized USA address and return the 5 digit zip code" ,
4+ "minimum-stability" : " stable" ,
5+ "license" : " GPL-3.0-or-later" ,
6+ "authors" : [
7+ {
8+ "name" : " Jason Olson"
9+ }
10+ ],
11+ "require" : {
12+ "php" : " >=7.4" ,
13+ "ext-curl" : " *"
14+
15+ },
16+ "autoload" : {
17+ "psr-4" : {
18+ "RedWebDev\\ usps_address_validation\\ " : " src"
19+ }
20+ }
21+ }
Original file line number Diff line number Diff line change 2222// example code shown below:
2323
2424require ('USPS.php ' );
25- use RedWebDev \USPS ;
2625
27- $ uspsZip = new USPS ('Consumer Key ' ,'Consumer Secret ' ); // insert your api key from USPS
26+ $ uspsZip = new RedWebDev \ uspszipcode ('Consumer Key ' ,'Consumer Secret ' ); // insert your api key from USPS
2827
2928$ address = '1600 Amphitheatre Parkway ' ; // address line is required
3029$ city = 'Mountain View ' ;
3130$ state = 'CA ' ; //looking for the two character state
3231
33- $ zipcode = $ uspsZip ->getNormalized ($ address , $ city , $ state );
32+ $ zipcode = $ uspsZip ->getZipCode ($ address , $ city , $ state );
3433
3534echo "Zip Code: " . $ zipcode ;
Original file line number Diff line number Diff line change 2020
2121namespace RedWebDev ;
2222
23- class USPS
23+ class uspszipcode
2424{
2525
2626 private string $ key ;
@@ -53,7 +53,7 @@ private function getOauthV3Token(): string
5353 return $ data ['access_token ' ];
5454 }
5555
56- public function getNormalized ($ address , $ city , $ state ): ?int
56+ public function getZipCode ($ address , $ city , $ state ): ?int
5757 {
5858 $ token = $ this ->getOauthV3Token ();
5959 $ authorization = "Authorization: Bearer " .$ token ;
You can’t perform that action at this time.
0 commit comments