verify addresses using smartystreets api
Sometimes the best way to learn a new API is to hit the ground running. Or, as Tony Stark says, “Sometimes you have to run before you can walk.” In accordance, here are some resources to help you fly (like Ironman does).
- function Address_Verification($add1=null,$add2=null,$add3=null)
- {
- // Customize this (get ID/token values in your SmartyStreets account)
- $authId = urlencode(“AUTH_ID_HERE”);
- $authToken = urlencode(“AUTH_TOKEN_HERE”);
- // Address input
- $input1 = urlencode($add1); // home address
- $input2 = urlencode($add2); // city and state here
- $input3 = urlencode($add3); // zip here
- // Build the URL
- $req = “https://api.qualifiedaddress.com/street-address/?street={$input1}&city={$input2}&state={$input3}&auth-id={$authId}&auth-token={$authToken}”;
- // GET request and turn into associative array
- $result = json_decode(file_get_contents($req,true));
- if(!emptyempty($result))
- {
- foreach ($result as $data)
- {
- return $data->analysis->active;
- }
- }
- else{ return “n”; }
- }
More info about API : http://smartystreets.com/products/liveaddress-api