-
-
14 Dec 2012 06:54:39 UTC
- Distribution: WWW-HostipInfo
- Module version: 0.14
- Source (raw)
- Browse (raw)
- Changes
- How to Contribute
- Repository
- Issues (1)
- Testers (534 / 334 / 0)
- Kwalitee
Bus factor: 0- 83.62% Coverage
- License: open_source
- Activity
24 month- Tools
- Download (10.25KB)
- MetaCPAN Explorer
- Permissions
- Subscribe to distribution
- Permalinks
- This version
- Latest version
and 1 contributors- Makamaka Hannyaharamitu (makamaka[at]cpan.org)
- Dependencies
- LWP
- Test::More
- and possibly others
- Reverse dependencies
- CPAN Testers List
- Dependency graph
NAME
WWW::HostipInfo - get a country and city information from ip address via www.hostip.info API.
SYNOPSIS
use WWW::HostipInfo; my $hostip = new WWW::HostipInfo; my $ip = 'xxx.xxx.xxx.xxx'; my $info = $hostip->get_info($ip); if($info->is_private){ warn "This is a private ip address." } my $country_code = $info->code; my $city_name = $info->city; my $region = $info->region; # if any $info = $hostip->recent_info->country_name; # fetch most recent data print WWW::HostipInfo->new($ip)->get_info->city; # shortcut
DESCRIPTION
This module gets a country and city information from ip address via www.hostip.info API.
METHODS
new
$hostip = WWW::HostipInfo->new(); $hostip = WWW::HostipInfo->new( $ip ); $hostip = WWW::HostipInfo->new( { ip => $ip, url => $url, ua => $user_agent } );
returns a WWW::HostipInfo object. This method can take an ip address or a hash reference optionally.
ip
$ip = $hostip->ip([$ip]);
setter / getter to the ip address.
url
$url = $hostip->url([$url]);
setter / getter to the HostipInfo API. Default is
api.hostip.info
.ua
$user_agent = $hostip->ua([$user_agent]);
setter / getter to the user agent. Default is
LWP::UserAgent
.get_info
$info = $hostip->get_info();
returns a WWW::HostipInfo::Info object. If the method can't get a information, will return
undef
.recent_info
$info = $hostip->get_info();
returns a
WWW::HostipInfo::Info
object.WWW::HostipInfo::Info
With
get_info()
, WWW::HostipInfo object returns WWW::HostipInfo::Info object.METHODS
getters for informations.
- country_code
-
return the cuntry code. If private ip address is used, the code is 'XX'.
- code
-
an alias to country_code
- country_name
-
return the cuntry name.
- name
-
an alias to country_name
- country
-
an alias to country_name
- city
-
return the city name as long as it is not unknown.
- region
-
return state code if the coutnry is US.
- latitude
- longitude
- ip
- is_private
-
If private ip address is used, returns true.
- has_unknown_city
-
If the object has no data for city, returns true.
- has_unknown_country
-
If the object has no data for country, returns true.
SEE ALSO
AUTHOR
Makamaka Hannyaharamitu, <makamaka[at]cpan.org>
COPYRIGHT AND LICENSE
Copyright 2005, 2009-2012 by Makamaka Hannyaharamitu
This library is licensed under GNU GENERAL PUBLIC LICENSE
Module Install Instructions
To install WWW::HostipInfo, copy and paste the appropriate command in to your terminal.
cpanm WWW::HostipInfo
perl -MCPAN -e shell install WWW::HostipInfo
For more information on module installation, please visit the detailed CPAN module installation guide.