X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fmisc%2Fxmlhttp-censustract.html;h=855e172e233c2c0aad835ef6b220c005a5ab9d2a;hb=HEAD;hp=8a76860472c4f24a212a87961b34545a90ff7c5a;hpb=929783d1045757abbe5c84ff2439547b0f8eca23;p=freeside.git diff --git a/httemplate/misc/xmlhttp-censustract.html b/httemplate/misc/xmlhttp-censustract.html index 8a7686047..855e172e2 100644 --- a/httemplate/misc/xmlhttp-censustract.html +++ b/httemplate/misc/xmlhttp-censustract.html @@ -5,10 +5,19 @@ my $DEBUG = 0; my $conf = new FS::Conf; -my $return = {}; -my $url = "http://data.fcc.gov/api/block/find?format=json&censusYear=" . $cgi->param('census_year') . "&latitude=" . $cgi->param('lat') . "&longitude=" . $cgi->param('lon'); +## 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); - \ No newline at end of file +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"; +} + +