summaryrefslogtreecommitdiff
path: root/httemplate/misc/xmlhttp-censustract.html
blob: 855e172e233c2c0aad835ef6b220c005a5ab9d2a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<% $return %>\
<%init>

my $DEBUG = 0;

my $conf = new FS::Conf;

## new api link, see doc https://geo.fcc.gov/api/census/
my $url = "https://geo.fcc.gov/api/census/block/find?format=json&censusYear=" . $cgi->param('census_year') . "&latitude=" . $cgi->param('lat') . "&longitude=" . $cgi->param('lon');

my $ua = new LWP::UserAgent;
$ua->agent('Freeside/'. $FS::VERSION); #libwww* elicits "403 Forbidden"
my $res = $ua->get($url);

my $return = '';
if ( $res->is_success ) {
  $return = $res->decoded_content;
} else {
  #better error handling?  well, hopefully the site is reliable enough
  warn 'Error from geo.fcc.gov: '. $res->status_line. "\n";
}

</%init>