GetPutDelete Posted April 2, 2010 Share Posted April 2, 2010 Questions in the title really, has anyone heard of one? Quote Link to comment https://forums.phpfreaks.com/topic/197369-free-address-lookup-api-based-on-postcode/ Share on other sites More sharing options...
oni-kun Posted April 16, 2010 Share Posted April 16, 2010 Questions in the title really, has anyone heard of one? There are many free geolocation services out there, One notably maxmind's services, You can filter the database yourself or use said software to get the lookup. Quote Link to comment https://forums.phpfreaks.com/topic/197369-free-address-lookup-api-based-on-postcode/#findComment-1042858 Share on other sites More sharing options...
muzzs Posted December 13, 2010 Share Posted December 13, 2010 Use the Google Maps API. I recently posted a blog post on exactly this at http://www.murraypicton.com/2010/12/free-uk-postcode-lookup-using-the-google-maps-api/ Hope it helps! Quote Link to comment https://forums.phpfreaks.com/topic/197369-free-address-lookup-api-based-on-postcode/#findComment-1146916 Share on other sites More sharing options...
malkocoglu Posted January 16, 2015 Share Posted January 16, 2015 // First, we need to take their postcode and get the lat/lng pair: $postcode = $_REQUEST['postcode']; // Sanitize their postcode: $search_code = urlencode($postcode); $url = 'http://maps.googleapis.com/maps/api/geocode/json?address=' . $search_code . '&sensor=false'; $json = json_decode(file_get_contents($url)); $lat = $json->results[0]->geometry->location->lat; $lng = $json->results[0]->geometry->location->lng; // Now build the lookup: $address_url = 'http://maps.googleapis.com/maps/api/geocode/json?latlng=' . $lat . ',' . $lng . '&sensor=false'; $address_json = json_decode(file_get_contents($address_url)); $address_data = $address_json->results[0]->address_components; $street = str_replace('Dr', 'Drive', $address_data[1]->long_name); $town = $address_data[2]->long_name; $county = $address_data[3]->long_name; $city = $address_data[4]->long_name; $country = $address_data[5]->long_name; $array = array('street' => $street, 'town' => $town, 'city' => $city, 'country' => $country); //echo json_encode($array); echo $array = implode(", ",$array); Quote Link to comment https://forums.phpfreaks.com/topic/197369-free-address-lookup-api-based-on-postcode/#findComment-1503161 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.