X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=httemplate%2Fmisc%2Fxmlhttp-censustract.html;fp=httemplate%2Fmisc%2Fxmlhttp-censustract.html;h=855e172e233c2c0aad835ef6b220c005a5ab9d2a;hp=985fb90e510c5999495d77acf5861fe8a33596bf;hb=850f7e02ff0ca9f3514989d7d6c2a0ab96ac4e06;hpb=bf9b266acafce57cfa532801c00d45dc4eab765c diff --git a/httemplate/misc/xmlhttp-censustract.html b/httemplate/misc/xmlhttp-censustract.html index 985fb90e5..855e172e2 100644 --- a/httemplate/misc/xmlhttp-censustract.html +++ b/httemplate/misc/xmlhttp-censustract.html @@ -5,12 +5,19 @@ my $DEBUG = 0; my $conf = new FS::Conf; -my $return = {}; - ## 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'); -use LWP::Simple; -my $return = get $url; +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"; +} - \ No newline at end of file +