WebService::IFConfig::Client - Client for Martin Polden's https://ifconfig.co
use strict; use warnings; use 5.12.0; use feature qw/say/; use WebService::IFConfig::Client; my $ifconfig = WebService::IFConfig::Client->new(); say $ifconfig->get_city; say $ifconfig->get_country; say $ifconfig->get_hostname; say $ifconfig->get_ip; say $ifconfig->get_ip_decimal; # Time passes ... # Request again $ifconfig->request;
Calling new() with no arguments, defaults to requesting immediately from https://ifconfig.co.
new()
To defer requesting, the data you can pass the argument 'run' => 0.
'run' => 0
To use a different server, pass 'server' => $my_server.
'server' => $my_server
Constructor to create an new client. Default values are
Argument Default Meaning -------- ------- ------- run 1 1 means run immediately. 0 means do not run until a request is made. server https://ifconfig.co/json IPD Server, but you can run your own and provide it here.
Get the URL this client is configured to talk to
Set the URL this client is configured to talk to
Get the HTTP Response Code of the latest request. Returns 0 if no request has been made.
Returns 1 if the HTTP Response Code of the latest request was 200, or 0 if not. Returns undef if no request has been made.
Makes a(nother) request from the server.
Get the City name. Forces a request if no valid data.
Get the Country name. Forces a request if no valid data.
Get the Hostname. Forces a request if no valid data.
Get the IP address. Forces a request if no valid data.
Get a decimal representation of the IP. Forces a request if no valid data.
Nic Doye <nic@worldofnic.org>
None. None whatsoever. (This is a lie).
Copyright 2017 Nicolas Doye 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 WebService::IFConfig::Client, copy and paste the appropriate command in to your terminal.
cpanm
cpanm WebService::IFConfig::Client
CPAN shell
perl -MCPAN -e shell install WebService::IFConfig::Client
For more information on module installation, please visit the detailed CPAN module installation guide.