1. Go to this page and download the library: Download chinafuturelink/geo library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
chinafuturelink / geo example snippets
use Fu\Geo\GeoCoder;
use Fu\Geo\Service\Coordinary\TencentCoordinaryLocationService;
const KEY = "YOUR-TENCENT-GEO-SERVICE-KEY";
$latitude = 29.60001;
$longitude = 91.00001;
$service = new TencentCoordinaryLocationService(KEY);
$response = $service->getLocation($latitude, $longitude);
if ($response->isOk()) {
$area = $response->getArea();
$area->nation; // 中国
$area->lv1; // 西藏自治区
$area->lv2; // 拉萨市
$area->lv3; // 堆龙德庆区
} else {
// get the response raw data...
var_dump($response->getRaw());
}
use Fu\Geo\IpCoder;
use Fu\Geo\Service\Ip\TencentIpLocationService;
const KEY = "YOUR-TENCENT-GEO-SERVICE-KEY";
$ip = '171.221.208.34';
$service = new TencentIpLocationService(KEY);
$response = $service->getLocation($ip);
if ($response->isOk()) {
$area = $response->getArea()
$area->nation; // 中国
$area->lv1; // 四川省
$area->lv2; // 成都市
$area->lv3; // 温江区
} else {
// get the response raw data...
var_dump($response->getRaw());
}
use Fu\Geo\IpCoder;
use Fu\Geo\Service\Phone\AliPhoneLocationService;
const KEY = "YOUR-ALI-SERVICE-KEY";
$areaCode = '86';
$phone = '13880799123';
$service = new AliPhoneLocationService(KEY);
$response = $service->getLocation($areaCode, $phone);
if ($response->isOk()) {
$area = $response->getArea()
$area->nation; // 中国
$area->lv1; // 四川省
$area->lv2; // 成都市
$area->lv3; // 温江区
} else {
// get the response raw data...
var_dump($response->getRaw());
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.