Loading...
web2.0

Geo localisation par IP

Si vous désirez connaitre la provenance de vos visiteurs, voici deux méthodes pour geo localiser. Bien sûr ce positionnement n’est pas très précis car l’IP dépend de votre FAI, mais la localisation reste intéressante surtout si l’on a des visiteurs du monde entier.

Méthode I en javascript via les API Google : pour obtenir une API KEY

Step 1: Charger Google AJAX API script

<script type="text/javascript" src="http://www.google.com/jsapi?key=API_KEY_GOES_HERE"></script>

Step 2: Extraire la localisation par google.loader.ClientLocation

if(google.loader.ClientLocation)
{
	visitor_lat = google.loader.ClientLocation.latitude;
	visitor_lon = google.loader.ClientLocation.longitude;
	visitor_city = google.loader.ClientLocation.address.city;
	visitor_region = google.loader.ClientLocation.address.region;
	visitor_country = google.loader.ClientLocation.address.country;
	visitor_countrycode = google.loader.ClientLocation.address.country_code;
}
else
{
	// pas trouve
}

Deuxième méthode II en PHP :

< ?php		
	 $IpAddress=$_SERVER["REMOTE_ADDR"];
	 $adress = 'http://www.geobytes.com/IpLocator.htm?GetLocation&template=php3.txt&IpAddress='.$IpAddress;
	 $tags = get_meta_tags($adress);
print $tags['city'];  // city name
print $tags['country'];  // country name
?>

14 comments
  1. yeezy

    Needed to post you a bit of note to finally say thanks a lot yet again on your gorgeous techniques you’ve featured on this page. This has been quite particularly generous with people like you to supply without restraint all that numerous people could have offered for sale as an electronic book to get some money on their own, most importantly given that you could have done it in case you considered necessary. These creative ideas likewise acted like the good way to be sure that many people have the identical zeal similar to my very own to know significantly more regarding this problem. Certainly there are some more enjoyable situations in the future for individuals who find out your site.

  2. supreme clothing

    I would like to point out my respect for your kind-heartedness giving support to individuals who require help on that idea. Your personal commitment to getting the solution all through has been exceptionally invaluable and have continuously encouraged guys and women just like me to get to their dreams. Your personal warm and friendly recommendations can mean a great deal a person like me and additionally to my peers. Regards; from each one of us.

  3. kobe shoes

    I really wanted to post a brief remark to say thanks to you for the great hints you are posting here. My time-consuming internet look up has now been paid with pleasant insight to talk about with my family members. I would admit that many of us readers actually are undeniably blessed to be in a fine website with very many wonderful individuals with insightful techniques. I feel truly blessed to have used the web pages and look forward to tons of more fabulous minutes reading here. Thanks again for everything.

  4. pg 1

    I want to point out my affection for your generosity for individuals that really need help with this important concept. Your very own dedication to passing the solution all around had been remarkably informative and has regularly empowered some individuals much like me to attain their dreams. Your personal useful facts denotes much a person like me and even more to my mates. Warm regards; from each one of us.

  5. pg shoes

    I am also writing to let you be aware of what a outstanding experience my child had reading through yuor web blog. She realized plenty of details, including how it is like to have a great giving nature to make men and women with no trouble learn about certain multifaceted topics. You actually exceeded readers’ desires. I appreciate you for offering these beneficial, trustworthy, revealing and as well as fun tips on this topic to Tanya.

Laisser un commentaire

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *