Skip to content

Instantly share code, notes, and snippets.

@lgladdy
Last active May 27, 2018 20:46
Show Gist options
  • Save lgladdy/9711141 to your computer and use it in GitHub Desktop.
Save lgladdy/9711141 to your computer and use it in GitHub Desktop.
BANES Council Data from iShare
$pc = 'ba11be';
//HACKY HACKY. GET the first properly in the postcode.
$url = 'http://isharemaps.bathnes.gov.uk/getdata.aspx?service=LocationSearch&RequestType=LocationSearch&location='.$pc.'&pagesize=1&startnum=1';
$data = json_decode(file_get_contents($url),true);
$x = $data['data'][0][4];
$y = $data['data'][0][5];
$id = $data['data'][0][0];
$things_we_care_about[] = 'Refuse and Recycling';
$things_we_care_about[] = 'Property Details';
$things_we_care_about[] = 'Council and Democracy';
$things_we_care_about[] = 'Parking Permit';
$things_we_care_about[] = 'Planning Applications';
$things_we_care_about[] = 'Licensing Applications';
$things_we_care_about[] = 'Multiple Occupancy Housing';
$things_we_care_about[] = 'Crime Prevention';
$things_we_care_about[] = 'Health and Social Care';
$datas = array();
foreach($things_we_care_about as $thing) {
$url = 'http://isharemaps.bathnes.gov.uk/getdata.aspx?RequestType=RSS&ms=BathNES/MyHouseLive&format=JSON&group='.urlencode($thing).'&uid='.$id;
$data = file_get_contents($url);
//This is hacky, but ishare returns invalid json by default sometimes, in that it returns non-seperated multiple json objects. Split them out.
$split = str_replace('}{', '}}{{', $data);
$split = explode('}{', $split);
foreach($split as $data) {
$datas[$thing][] = json_decode($data,true);
}
}
$nearest_we_care_about[] = 'Transport and Streets';
$nearest_we_care_about[] = 'Parks and Open Spaces';
$nearest_we_care_about[] = 'Fitness and Recreation';
$nearest_we_care_about[] = 'Libraries';
$nearest_we_care_about[] = 'Play Schools and Nurseries';
$nearest_we_care_about[] = 'Primary Schools';
$nearest_we_care_about[] = 'Secondary Schools';
$nearest_we_care_about[] = 'Colleges and Further Education';
foreach($nearest_we_care_about as $thing) {
$url = 'http://isharemaps.bathnes.gov.uk/getdata.aspx?RequestType=RSS&ms=BathNES/MyNearest&format=JSON&group='.urlencode($thing).'&uid='.$id;
$data = file_get_contents($url);
$split = str_replace('}{', '}}{{', $data);
$split = explode('}{', $split);
foreach($split as $data) {
$datas[$thing][] = json_decode($data,true);
}
}
//Use $datas here. It has a bunch of arrays of all the data the council have on isharemaps.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment