How to get all UK addresses by postal code
I will show you how you can get all addresses of UK by postal code. For this i will used an API https://api.getaddress.io. First I will create account on getaddress.io and after created an account generate an API KEY and use that key in your API.
I'm using the following code to get UK addresses by postal code.
<?phpif(isset($_POST['postsubmit'])){$postalcode = $_POST['postal'];$apiURL = "https://api.getaddress.io/find/".$postalcode."?api-key=API KEY HERE";$response = get_web_page($apiURL);$resArr = array();$resArr = json_decode($response);echo "<pre>"; print_r($resArr); echo "</pre>";function get_web_page($url) {$options = array(CURLOPT_RETURNTRANSFER => true, // return web pageCURLOPT_HEADER => false, // don't return headersCURLOPT_FOLLOWLOCATION => true, // follow redirectsCURLOPT_MAXREDIRS => 10, // stop after 10 redirectsCURLOPT_ENCODING => "", // handle compressedCURLOPT_USERAGENT => "test", // name of clientCURLOPT_AUTOREFERER => true, // set referrer on redirectCURLOPT_CONNECTTIMEOUT => 120, // time-out on connectCURLOPT_TIMEOUT => 120, // time-out on response);$ch = curl_init($url);curl_setopt_array($ch, $options);$content = curl_exec($ch);curl_close($ch);return $content;}}?>
HTML Form
Also Read: Get logged in user info in WordPress
<div class="container"><h2>Get Address by Postal Code</h2><form action="" method="post"><div class="form-group"><label for="Postal Code">Postal Code:</label><input type="text" class="form-control" id="email" placeholder="Postal Code" name="postal"></div><button type="submit" name="postsubmit" class="btn btn-primary">Submit</button></form></div>
I will show you how you can get all addresses of UK by postal code. For this i will used an API https://api.getaddress.io. First I will create account on getaddress.io and after created an account generate an API KEY and use that key in your API.
I'm using the following code to get UK addresses by postal code.
<?phpif(isset($_POST['postsubmit'])){$postalcode = $_POST['postal'];$apiURL = "https://api.getaddress.io/find/".$postalcode."?api-key=API KEY HERE";$response = get_web_page($apiURL);$resArr = array();$resArr = json_decode($response);echo "<pre>"; print_r($resArr); echo "</pre>";function get_web_page($url) {$options = array(CURLOPT_RETURNTRANSFER => true, // return web pageCURLOPT_HEADER => false, // don't return headersCURLOPT_FOLLOWLOCATION => true, // follow redirectsCURLOPT_MAXREDIRS => 10, // stop after 10 redirectsCURLOPT_ENCODING => "", // handle compressedCURLOPT_USERAGENT => "test", // name of clientCURLOPT_AUTOREFERER => true, // set referrer on redirectCURLOPT_CONNECTTIMEOUT => 120, // time-out on connectCURLOPT_TIMEOUT => 120, // time-out on response);$ch = curl_init($url);curl_setopt_array($ch, $options);$content = curl_exec($ch);curl_close($ch);return $content;}}?>
HTML Form
Also Read: Get logged in user info in WordPress
<div class="container"><h2>Get Address by Postal Code</h2><form action="" method="post"><div class="form-group"><label for="Postal Code">Postal Code:</label><input type="text" class="form-control" id="email" placeholder="Postal Code" name="postal"></div><button type="submit" name="postsubmit" class="btn btn-primary">Submit</button></form></div>
Recommanded Articles
- Get Facebook long live access token in AWS Lambda function
- How to make image background transparent using PHP
- Paypal credit card payment on website in PHP
- Capture page screenshot by URL PHP script
- How to get all UK addresses by postal code
- API versioning in Laravel App
- Get all the lists from Mailchimp account using CURL
- Create a LEAD in ZOHO CRM using Node JS
- Create a LEAD in ZOHO CRM using API
- Add new subscriber in a Klaviyo list API

Latest Comments