GeoIP tagging - Where to start?

Wraithmanilian 0 Tallied Votes 433 Views Share

If you ever go to http://www.hostip.info/, you will find a Community Geotarget IP Project. The great thing about it is that it is free to use. :)

Now, this is just a snippet of code to begin working in the world of GeoIPs. There's a lot more info to be gotten, and if you go to http://www.hostip.info/use.html, you will find many different ways of calling the information that you need.

Just my 2¢. Thought I'd share.

<?php

$ip = getenv('REMOTE_ADDR');
$url = "http://api.hostip.info/get_html.php?".$ip;

$contents = file_get_contents($url);
$values = split("[\n|\r]",$contents);

foreach($values as $vals) {
	$myvalues = split(": ",$vals);
	$line = "<strong>".$myvalues[0].":</strong> ".$myvalues[1]."<br />";
	echo $line;
}

?>
rom. 13 Newbie Poster

geotargeting hadn't crossed my mind, cheers
makes for a nice IP logging system ;)
however split() has been deprecated as of 5.3.0, best to use preg_split()

thanks again

Wraithmanilian 1 Junior Poster

Thanks for the heads up on split(). 5.3.0 had only been out for 8 months or so and old habits are hard to break. :)

sammry -3 Light Poster

this does not work for Indian based ips, check here

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.