All Projects → DavidePastore → ipinfo

DavidePastore / ipinfo

Licence: GPL-3.0 license
A wrapper around the ipinfo.io services

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to ipinfo

Track Ip
Advanced Ip Tracker Tool
Stars: ✭ 150 (+194.12%)
Mutual labels:  geolocation, ip
Geolocate-IP-Browser-Extension
A browser extension, which shows you the origin of your IP address.
Stars: ✭ 21 (-58.82%)
Mutual labels:  geolocation, ip
pikaz-location
定位插件(限中国)
Stars: ✭ 78 (+52.94%)
Mutual labels:  geolocation, ip
Snoop
Snoop — инструмент разведки на основе открытых данных (OSINT world)
Stars: ✭ 886 (+1637.25%)
Mutual labels:  geolocation, ip
Iplocation
Get ip location information.
Stars: ✭ 70 (+37.25%)
Mutual labels:  geolocation, ip
Ipdata
🌐 An IP lookup system utilizing open datasets
Stars: ✭ 58 (+13.73%)
Mutual labels:  geolocation, ip
express-ip
An Express Middleware for getting IP information
Stars: ✭ 28 (-45.1%)
Mutual labels:  geolocation, ip
Country Ip Blocks
CIDR country-level IP data, straight from the Regional Internet Registries, updated hourly.
Stars: ✭ 100 (+96.08%)
Mutual labels:  geolocation, ip
Mercury
Mercury is a hacking tool used to collect information and use the information to further hurt the target
Stars: ✭ 236 (+362.75%)
Mutual labels:  geolocation, ip
go
Official Golang client library for the ipdata API
Stars: ✭ 21 (-58.82%)
Mutual labels:  geolocation
ipinfodb-php
PHP library to query free IPInfoDB API service.
Stars: ✭ 15 (-70.59%)
Mutual labels:  geolocation
GoGoCarto
This repo has been moved to https://gitlab.adullact.net/pixelhumain/GoGoCarto since 17/12/2018
Stars: ✭ 43 (-15.69%)
Mutual labels:  geolocation
radar-sdk-android
Android SDK for Radar, the leading geofencing and location tracking platform
Stars: ✭ 57 (+11.76%)
Mutual labels:  geolocation
exploring-my-neighborhood
track all your moves and visualize them!
Stars: ✭ 16 (-68.63%)
Mutual labels:  geolocation
GeoLite2-City
GeoLite2-City.mmdb.gz CDN files based on Free Open Source CDN jsDelivr!
Stars: ✭ 170 (+233.33%)
Mutual labels:  ip
go-external-ip
a Golang library to get your external ip from multiple services
Stars: ✭ 55 (+7.84%)
Mutual labels:  ip
IPpy
🚀 Ping IP addresses and domains in parallel to find the accessible and inaccessible ones.
Stars: ✭ 54 (+5.88%)
Mutual labels:  ip
google-maps-places-geolocation-for-your-ionic-app
Ionic example app of how to add Google maps, places, geolocation and related features into an Ionic Framework app.
Stars: ✭ 13 (-74.51%)
Mutual labels:  geolocation
cloudflare-ddns
A script to update your Cloudflare DNS records at a glance.
Stars: ✭ 152 (+198.04%)
Mutual labels:  ip
LaravelPostcodes
A service wrapper around postcodes.io
Stars: ✭ 73 (+43.14%)
Mutual labels:  geolocation

ipinfo

Latest version Build Status Coverage Status Quality Score Total Downloads PSR2 Conformance

A wrapper around the ipinfo.io services.

Install

You can install the library using composer:

$ composer require davidepastore/ipinfo

How to use

Settings

Token

You can set your token when you instantiate the object but it's not mandatory.

$ipInfo = new DavidePastore\Ipinfo\Ipinfo(array(
	"token" => "your_api_key"
));

cURL options

The cURL options to use while trying to connect when you instantiate the object:

$ipInfo = new DavidePastore\Ipinfo\Ipinfo(array(
	"curlOptions" => array(
            CURLOPT_CONNECTTIMEOUT => 1,
            CURLOPT_TIMEOUT => 2,
            CURLOPT_CAINFO => __DIR__ . "/cacert.pem"
    )
));

Read details about the given ip

You can read all the properties from the given ip.

//Get all the properties
$host = $ipInfo->getFullIpDetails("8.8.8.8");

//Get only a single property (this could save bandwidth)
$city = $ipInfo->getSpecificField("8.8.8.8", DavidePastore\Ipinfo\Ipinfo::CITY);

Read details about your ip

You can read all the properties from your ip.

//Get all the properties
$host = $ipInfo->getYourOwnIpDetails();

//Get only a single property (this could save bandwidth)
$city = $ipInfo->getYourOwnIpSpecificField(DavidePastore\Ipinfo\Ipinfo::CITY);

Get info from the host

After obtaining the Host instance you can read all the properties or each of them individually.

//Read all the properties
$city = $host->getCity();
$country = $host->getCountry();
$hostname = $host->getHostname();
$ip = $host->getIp();
$loc = $host->getLoc();
$org = $host->getOrg();
$phone = $host->getPhone();
$postal = $host->getPostal();
$region = $host->getRegion();

//Get the associative array with all the properties
$properties = $host->getProperties();

Read only a field

There are different constants that you could use to read specific field value from an Ipinfo instance using the getSpecificField() and getYourOwnIpSpecificField() methods:

IpInfo::IP; //For the ip address
IpInfo::HOSTNAME; //For the hostname
IpInfo::LOC; //For the loc
IpInfo::ORG; //For the org
IpInfo::CITY; //For the city
IpInfo::REGION; //For the region
IpInfo::COUNTRY; //For the country
IpInfo::PHONE; //For the phone
IpInfo::POSTAL; //For the postal
IpInfo::GEO; //For the geo info. See the paragraph below for more info

Read only the Geo data (which is faster)

By using the getIpGeoDetails() method you will get less fields. This call tends to be faster than getFullIpDetails() so use this call in case you only need the following fields:

IpInfo::IP; //For the ip address
IpInfo::CITY; //For the city
IpInfo::REGION; //For the region
IpInfo::COUNTRY; //For the country
IpInfo::PHONE; //For the phone
IpInfo::POSTAL; //For the postal

These fields will be empty:

IpInfo::HOSTNAME; //For the hostname
IpInfo::LOC; //For the loc
IpInfo::ORG; //For the org

Error Handling

You can handle all the types of IpInfo exceptions by catching the IpInfoExceptionException:

use DavidePastore\Ipinfo\Exception\IpInfoExceptionException;

try {
    $host = $ipInfo->getFullIpDetails("8.8.8.8");
} catch (IpInfoExceptionException $e) {
    echo 'Caught exception: ',  $e->getMessage(), "\n";
}

Invalid Token Exception

It could happen that the token you are using to make the API call is not valid. You can handle it by catching the InvalidTokenException:

use DavidePastore\Ipinfo\Exception\InvalidTokenException;

try {
    $host = $ipInfo->getFullIpDetails("8.8.8.8");
} catch (InvalidTokenException $e) {
    echo 'Caught exception: ',  $e->getMessage(), "\n";
}

Rate Limit Exceed Exception

It could happen that your API call exceeds the rate limit. You can handle it by catching the RateLimitExceedException:

use DavidePastore\Ipinfo\Exception\RateLimitExceedException;

try {
    $host = $ipInfo->getFullIpDetails("8.8.8.8");
} catch (RateLimitExceedException $e) {
    echo 'Caught exception: ',  $e->getMessage(), "\n";
}

Wrong Ip Exception

It could happen that your API call is trying to obtain info about a wrong ip. You can handle it by catching the WrongIpException:

use DavidePastore\Ipinfo\Exception\WrongIpException;

try {
    $host = $ipInfo->getFullIpDetails("qwerty");
} catch (WrongIpException $e) {
    echo 'Caught exception: ',  $e->getMessage(), "\n";
}

Issues

If you have issues, just open one here.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].