├── example.php ├── composer.json ├── function_ipwhois.php ├── docs └── index.rst └── README.md /example.php: -------------------------------------------------------------------------------- 1 | "; 7 | print_r($location); 8 | echo ""; 9 | ?> 10 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ipwhois-io/ip-geolocation-api", 3 | "version": "1.0.0", 4 | "description": "A Simple php wrapper for https://ipwhois.io", 5 | "type": "library", 6 | "license": "MIT", 7 | "authors": [ 8 | { 9 | "name": "IPWHOIS.io", 10 | "homepage": "https://ipwhois.io/", 11 | "role": "Developer" 12 | } 13 | ], 14 | "require": { 15 | "guzzlehttp/guzzle": "~6.0", 16 | "nesbot/carbon": "~1.18", 17 | "php" : "^5.5 || ^7.0", 18 | "ext-json": "*" 19 | }, 20 | "require-dev": { 21 | "phpunit/phpunit": "^7", 22 | "phpunit/php-code-coverage": "^6.0" 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /function_ipwhois.php: -------------------------------------------------------------------------------- 1 | 15 | -------------------------------------------------------------------------------- /docs/index.rst: -------------------------------------------------------------------------------- 1 | ************************** 2 | ipwhois.io | IP Geolocation API - PHP SDK 3 | ************************** 4 | 5 | Overview 6 | ============ 7 | 8 | This `IP Geolocation API `_ service is designed for quick and easy visitors IP geolocation integration into your script or website. Get rid of setting up local GeoIP libraries and forget about regular updates. Our neural network analyzes dozens of sources and almost real-time updates the database. 9 | 10 | Quick Start Guide 11 | ============ 12 | 13 | You can call the API by sending HTTP ``GET requests`` to: 14 | 15 | .. code:: console 16 | 17 | http://ipwhois.app/json/{IP} 18 | 19 | ``{IP}`` can be an IPv4 or IPv6 address, or none to use the current IP address. 20 | 21 | Note: Complete documentation to use this SDK is also available at https://ipwhois.io/documentation 22 | 23 | 24 | Basic Usage 25 | ============ 26 | Call method 27 | 28 | .. code:: console 29 | 30 | get_ipwhois($ip, $format, $lang, $apiKey) 31 | 32 | passing IP address as parameters (rest of the parameters are optional) and it will return the Geolocation for the passed IP address. 33 | 34 | 35 | Example 36 | ============ 37 | 38 | .. code:: php 39 | 40 | "; 45 | print_r($location); 46 | echo ""; 47 | 48 | function get_ipwhois($ip, $format = "json", $lang = "en", $apiKey = "") { 49 | $url = "http://".($apiKey != '' ? 'ipwhois.pro' : 'ipwhois.app')."/".$format."/".$ip."?lang=".$lang.($apiKey != '' ? '&key='.$apiKey : ''); 50 | $cURL = curl_init(); 51 | curl_setopt($cURL, CURLOPT_URL, $url); 52 | curl_setopt($cURL, CURLOPT_HTTPGET, true); 53 | curl_setopt($cURL, CURLOPT_RETURNTRANSFER, true); 54 | curl_setopt($cURL, CURLOPT_HTTPHEADER, array( 55 | 'Content-Type: application/json', 56 | 'Accept: application/json' 57 | )); 58 | return json_decode(curl_exec($cURL),true); 59 | } 60 | ?> 61 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

IP Geolocation API - PHP SDK

2 | 3 |

Overview

4 | 5 | This IP Geolocation API service is designed for quick and easy visitors IP geolocation integration into your script or website. Get rid of setting up local GeoIP libraries and forget about regular updates. Our neural network analyzes dozens of sources and almost real-time updates the database. 6 | 7 |

Quick Start Guide

8 | 9 | You can call the API by sending HTTP GET requests to http://ipwho.is/{IP} 10 | 11 | {IP} can be an IPv4 or IPv6 address, or none to use the current IP address. 12 | 13 | Note: Complete documentation to use this API is also available at IP Geolocation API Documentation. 14 | 15 |

System Requirements

16 | 17 | Internet connection is required to run this component. 18 | 19 |

Basic Usage

20 | 21 | Call method get_ipwhois($ip, $format, $lang, $apiKey) passing IP address as parameters (rest of the parameters are optional) and it will return the Geolocation for the passed IP address. To customize the geolocation response, you can pass the other parameters to get_ipwhois() method as described below: 22 | 23 | 48 | 49 |

Example

50 | 51 | ```php 52 | "; 58 | print_r($location); 59 | echo ""; 60 | 61 | function get_ipwhois($ip, $format = "json", $lang = "en", $apiKey = "") { 62 | $url = "http://".($apiKey != '' ? 'ipwhois.pro' : 'ipwho.is')."/".$ip."?lang=".$lang.($apiKey != '' ? '&key='.$apiKey : '')."&output=".$format; 63 | $cURL = curl_init(); 64 | curl_setopt($cURL, CURLOPT_URL, $url); 65 | curl_setopt($cURL, CURLOPT_HTTPGET, true); 66 | curl_setopt($cURL, CURLOPT_RETURNTRANSFER, true); 67 | curl_setopt($cURL, CURLOPT_HTTPHEADER, array( 68 | 'Content-Type: application/json', 69 | 'Accept: application/json' 70 | )); 71 | return json_decode(curl_exec($cURL),true); 72 | } 73 | ?> 74 | ``` 75 | --------------------------------------------------------------------------------