free hit counter

SmartyStreets Address Verification API Integration In Php

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).

 

  1. function Address_Verification($add1=null,$add2=null,$add3=null)  
  2. {  
  3.     // Customize this (get ID/token values in your SmartyStreets account)  
  4.     $authId = urlencode(“AUTH_ID_HERE”);  
  5.     $authToken = urlencode(“AUTH_TOKEN_HERE”);  
  6.     // Address input  
  7.     $input1 = urlencode($add1);  // home address  
  8.     $input2 = urlencode($add2);  // city and state here  
  9.     $input3 = urlencode($add3); // zip here  
  10.     // Build the URL  
  11.     $req = “https://api.qualifiedaddress.com/street-address/?street={$input1}&city={$input2}&state={$input3}&auth-id={$authId}&auth-token={$authToken}”;  
  12.     // GET request and turn into associative array  
  13.     $result = json_decode(file_get_contents($req,true));  
  14.     if(!emptyempty($result))  
  15.     {  
  16.         foreach ($result as $data)  
  17.         {  
  18.             return  $data->analysis->active;  
  19.         }  
  20.     }  
  21.     elsereturn “n”; }  
  22.       
  23. }  

More info about API : http://smartystreets.com/products/liveaddress-api

Leave a Reply