Skip to content

Instantly share code, notes, and snippets.

@tomnomnom
Created December 9, 2013 17:03
Show Gist options
  • Save tomnomnom/7875919 to your computer and use it in GitHub Desktop.
Save tomnomnom/7875919 to your computer and use it in GitHub Desktop.
Hacky script for finding BT Address IDs
<?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