Skip to content

PHP Geoplugin API – Find location with IP address

Last updated on December 9, 2014

In this post i will show you, how to find the location based on the ip of the client. We gonna use geoPlugin’s geolocation web service.This web service allows you to find Location based upon the IP of the client. It shows country,region, City , latitude , longitude etc of the IP address. Its very easy to integrate in your web application, using following code snippet:

  function getIPInfo($ip) {
    return unserialize(file_get_contents('http://www.geoplugin.net/php.gp?ip='.$id));
  }

How to use :

    echo getIPInfo($_SERVER['REMOTE_ADDR']);

And it will return you the results. It supports various formats like PHP, JSON, ASP, XML etc. you can find the demo here

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Most Voted
Newest Oldest
Inline Feedbacks
View all comments