default to a session cookie instead of setting an explicit timeout, weird timezone...
[freeside.git] / httemplate / misc / xmlhttp-censustract.html
1 <% $return %>\
2 <%init>
3
4 my $DEBUG = 0;
5
6 my $conf = new FS::Conf;
7
8 ## new api link, see doc https://geo.fcc.gov/api/census/
9 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');
10
11 my $ua = new LWP::UserAgent;
12 $ua->agent('Freeside/'. $FS::VERSION); #libwww* elicits "403 Forbidden"
13 my $res = $ua->get($url);
14
15 my $return = '';
16 if ( $res->is_success ) {
17   $return = $res->decoded_content;
18 } else {
19   #better error handling?  well, hopefully the site is reliable enough
20   warn 'Error from geo.fcc.gov: '. $res->status_line. "\n";
21 }
22
23 </%init>