PHP code example of cxj / validate.address
1. Go to this page and download the library: Download cxj/validate.address library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
cxj / validate.address example snippets
$address = new Address(
"8039 Beach Blvd",
"",
"Buena Park",
"CA",
"90620"
);
$user = YOUR_USER_NAME; // Obtained from the USPS website:
// https://www.usps.com/business/web-tools-apis/#developers
$validate = new ValidateAddress(new CurlPost($user), new DomParser());
$response = $validate->validate($address);
echo sprintf("Corrected ZIP+4 Code: %s-%s\n",
$response->getAddress()->getZip5(),
$response->getAddress()->getZip4()
);