Geotargeting Examples

Example # Provider 1

Service Provider
MaxMind GeoLite Country (free & commercial)
Your IP Address
38.107.191.107
Country Code
US
Country Name
United States
Benchmark
0.061331033706665 sec

Source Code

<?php
	require_once('Net/GeoIP.php');
	
	$ip          = $_SERVER['REMOTE_ADDR'];
	$geoip       = Net_GeoIP::getInstance('lib/GeoIP.dat');
	$countryName = $geoip->lookupCountryName($ip);
	$countryCode = $geoip->lookupCountryCode($ip);
?>

Example # Provider 2

Service Provider
hostip.info (free)
Country Code
STATES
Country Name
UNITED
Benchmark
0.26005601882935 sec

Source Code

<?php
	require_once('HTTP/Request.php');
	
	$ip      = $_SERVER['REMOTE_ADDR'];
	$url     = "http://api.hostip.info/get_html.php?ip={$ip}";
	$req     = new HTTP_Request($url);
	$req->sendRequest();
   	$request = $req->getResponseBody();
?>