mattpower has asked for the wisdom of the Perl Monks concerning the following question:
Which successfully printsuse strict; use warnings; use LWP::Simple; # from CPAN use JSON qw( decode_json ); # from CPAN #get my address use LWP::UserAgent; my $ua = LWP::UserAgent->new; my $server_endpoint = "https://www.googleapis.com/geolocation/v1/geolo +cate?key=MY API KEY"; # set custom HTTP request header fields my $req = new HTTP::Request POST =>( $server_endpoint); $req->header('content-type' => 'application/json'); # add POST data to HTTP request body my $post_data = '{"homeMobileCountryCode" : 235, "homeMobileNetworkCode" : 77, "radioType" : "gsm", "carrier" : "BT Group", "considerIp" : "true"}'; $req->content($post_data); my $resp = $ua->request($req); my $message = $resp->decoded_content; print "Received Reply:$message\n";
What I need to do now is get the lat and lng values to use in a new script, but I just cant do it. I'm tryingReceived Reply:{ "location": { "lat": 53.4232611, "lng": -1.0836272999999998 }, "accuracy": 901.0 }
but I get the error messagemy $lat = $message->{"location"}{"lat"};
Please point me in the right directionCan't use string ("{ "location": { "lat": 53.423"...) as a HASH ref while "strict refs" in use at etc.e +tc.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Using Google APIs for Lattitude
by huck (Prior) on Jul 03, 2017 at 20:14 UTC | |
by stevieb (Canon) on Jul 03, 2017 at 21:27 UTC | |
by mattpower (Initiate) on Jul 04, 2017 at 08:02 UTC | |
|
Re: Using Google APIs for Lattitude
by stevieb (Canon) on Jul 03, 2017 at 20:02 UTC |