Is there a good PHP geolocation service?

I am looking for a good PHP geolocation service, so when I run my application, I might have something like:

<?php
$service = new GeoLocService();
echo $service->getLat();
echo $service->getLng();
?>

to get the user's position in latitude and logarithm.

+4
source share
4 answers

The geographic location must be made in the browser, as the server (i.e. PHP) will never know most of the relevant data. The main API for performing geolocation in a browser is Google, but you, as a developer, will not need to use this API; you should use a browser API that is standardized (although it is only supported in a few browsers).

, , IP-, , . IP-to-nation IP-to-location API, , . , , . , , , IP .

API- , Wi-Fi. Google, Lat/Long ( ).

? , , , Google Wi-Fis? , , Wi-Fi .

, , Wi-Fi.

, (, Javascript DOM), PHP, ; .

+10

MaxMind PHP API ... http://www.maxmind.com/app/php

+3

Geo-Loacaion API: http://dev.w3.org/geo/api/spec-source-v2.html

I am sure that the above documents will be very useful for you.

+1
source

PHP gets the real IP address, countries, city, state, languages โ€‹โ€‹of visitors

You can determine the real ip, guest proxy, languages, state, city. But for PHP Code, you must download the PHP source code from Github .

<?php
// Required Libraries
require_once("ip.codehelper.io.php");
require_once("php_fast_cache.php");

// New Class
$_ip = new ip_codehelper();

// Detect Real IP Address & Location
$real_client_ip_address = $_ip->getRealIP();
$visitor_location       = $_ip->getLocation($real_client_ip_address);

// Output result
echo $visitor_location['Country']."
";
echo "<pre>";
print_r($visitor_location);

In your case, you will get $ visitor_location ['RegionName'] from the returned result.

0
source

All Articles