Created
February 20, 2015 13:46
-
-
Save stephenkeable-allies/164acedfa55573d24f95 to your computer and use it in GitHub Desktop.
Basic PHP Country List Example using PostCoder Web. Find out more at - http://developers.alliescomputing.com/postcoder-web-api/geocoding/countries
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Insert your PostCoder Web API Key here | |
// Sign up for free at www.alliescomputing.com/postcoder/sign-up | |
$pcw_api_key = "YOUR-API-KEY-HERE"; | |
// URL we are calling with API key and url encoded postcode | |
$pcw_country_url = "http://ws.postcoder.com/pcw/". $pcw_api_key ."/country"; | |
// Get and JSON decode the response from the service | |
$response = json_decode(file_get_contents($pcw_country_url)); | |
// Basic display HTML below, using foreach | |
?> | |
<select> | |
<option>Select country...</option> | |
<?php foreach ($response as $country) : ?> | |
<option value="<?= $country->iso2 ?>"><?= $country->countryname ?></option> | |
<?php endforeach; ?> | |
</select> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment