Geo::IPinfo - Official Perl module to use ipinfo.io geolocation services
Version 1.0 - Initial release
Geo::IP provides an object-oriented perl interface to https://ipinfo.io geolocation services
A quick usage example:
use Geo::IPinfo; my $token = "1234567"; # if you have a valid token, use it my $ipinfo = Geo::IPinfo->new($token); # or, if you don't have a token, use this: # my $ipinfo = Geo::IPinfo->new(); # return a hash reference containing all IP related information my $data = $ipinfo->info("8.8.8.8"); if (defined $data) # valid data returned { print "Information about IP 8.8.8.8:\n"; for my $key (sort keys %$data ) { printf "%10s : %s\n", $key, $data->{$key}; } print "\n"; } else # invalid data obtained, show error message { print $ipinfo->error_msg . "\n"; } # retrieve only city information of the IP address my $city = $ipinfo->field("8.8.8.8", "city"); print "The city of 8.8.8.8 is $city\n";
Create an ipinfo object. The 'token' argument (string value) is optional.
If 'token' is specified, then it's used to overcome the default non-commercial limitation of 1,000 request/day (For more details, see https://ipinfo.io/pricing)
Returns a reference to a hash containing all information related to the IP address. In case of errors, returns undef, the error message can be retrieved with the function 'error_msg()'
The values returned are: ip, hostname, city, region, country, loc, org
Returns a reference to a hash containing only the geolocation related data. Returns undef in case of errors, the error message can be retrieved with the function 'error_msg'
It's usually faster than getting the full response using 'info()'
The values returned are: ip, loc, city, region, country
Returns a string with the contents of field_name for the specified IP address. Returns undef if the field is invalid
The possible values of 'field_name' are: ip, hostname, city, region, country, loc, org
Returns a string containing the error message of the last operation, it returns an empty string if the last operation was successful
Ben Dowling, <ben at change.me>
<ben at change.me>
Please report any bugs or feature requests to bug-geo-ipinfo at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Geo-IPinfo. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
bug-geo-ipinfo at rt.cpan.org
You can find documentation for this module with the perldoc command.
perldoc Geo::IPinfo
You can also look for information at:
RT: CPAN's request tracker (report bugs here)
http://rt.cpan.org/NoAuth/Bugs.html?Dist=Geo-IPinfo
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/Geo-IPinfo
CPAN Ratings
http://cpanratings.perl.org/d/Geo-IPinfo
Search CPAN
http://search.cpan.org/dist/Geo-IPinfo/
Copyright 2017 ipinfo.io.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
To install Geo::IPinfo, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Geo::IPinfo
CPAN shell
perl -MCPAN -e shell install Geo::IPinfo
For more information on module installation, please visit the detailed CPAN module installation guide.