diff options
| author | Ivan Kohler <ivan@freeside.biz> | 2022-04-27 13:50:39 -0700 |
|---|---|---|
| committer | Ivan Kohler <ivan@freeside.biz> | 2022-04-27 13:50:39 -0700 |
| commit | 314a04d3626bb2faaa5d3d4f0191d305a71d8ede (patch) | |
| tree | b74d5168d77b4ed89d8e65bbbc95bfc07f934886 /httemplate/misc/xmlhttp-censustract.html | |
| parent | 0c1bbe3f62b483feb841b8b958dc468e1c457c45 (diff) | |
restore correct workflow when no census match is found: offer map-based picker, RT#86245, RT#76968
Diffstat (limited to 'httemplate/misc/xmlhttp-censustract.html')
| -rw-r--r-- | httemplate/misc/xmlhttp-censustract.html | 17 |
1 files changed, 12 insertions, 5 deletions
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"; +} -</%init>
\ No newline at end of file +</%init> |
