Saturday, 27 September 2014

How To Get User Information in PHP

You can get all the information about the user into your website,using geoPlugin


Geo-localized javascript only

 

<script language="JavaScript" src="http://www.geoplugin.net/javascript.gp" 
type="text/javascript"></script>
 

PHP service

The PHP service is the most popular service and will return a PHP serialized array of all the information of your visitor. Described in detail here, and a quick quide is given below. 

Call this service in your script using 

http://www.geoplugin.net/php.gp?ip=xx.xx.xx.xx

echo var_export(unserialize(file_get_contents('http://www.geoplugin.net/php.gp
?ip='.$_SERVER['REMOTE_ADDR'])));
 
will output 
 
array (
  'geoplugin_request' => '122.177.116.77',
  'geoplugin_status' => 200,
  'geoplugin_credit' => 'Some of the returned data includes...',
  'geoplugin_city' => 'Delhi',
  'geoplugin_region' => 'Delhi',
  'geoplugin_areaCode' => '0',
  'geoplugin_dmaCode' => '0',
  'geoplugin_countryCode' => 'IN',
  'geoplugin_countryName' => 'India',
  'geoplugin_continentCode' => 'AS',
  'geoplugin_latitude' => '28.6667',
  'geoplugin_longitude' => '77.216698',
  'geoplugin_regionCode' => '07',
  'geoplugin_regionName' => 'Delhi',
  'geoplugin_currencyCode' => 'INR',
  'geoplugin_currencySymbol' => '₨',
  'geoplugin_currencySymbol_UTF8' => '₨',
  'geoplugin_currencyConverter' => '61.415',
)
 
 
For More methods, please go through http://www.geoplugin.com/quickstart. 
 
 
 

No comments:

Post a Comment