Created
December 9, 2013 17:03
-
-
Save tomnomnom/7875919 to your computer and use it in GitHub Desktop.
Hacky script for finding BT Address IDs
This file contains hidden or 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 | |
const HOUSE_NUMBER = 2; | |
const POSTCODE = 'LS1 4AP'; | |
const SERVICE_URL = 'http://www.productsandservices.bt.com/consumerProducts/v1/addressSearch.do'; | |
$query = http_build_query(array( | |
'postcode' => POSTCODE, | |
'house' => HOUSE_NUMBER, | |
'format' => 'json' | |
)); | |
$r = file_get_contents(SERVICE_URL.'?'.$query); | |
if (!$r){ | |
echo "Failed to fetch/parse JSON\n"; | |
exit(1); | |
} | |
$s = json_decode($r); | |
foreach ($s->addresses as $a){ | |
echo "{$a->addressId} - {$a->BuildingNumber} {$a->ThoroughfareName}, {$a->PostTown}\n"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment