library php-ip-location
利用 IP 查詢地理位置。
jfcherng/php-ip-location
利用 IP 查詢地理位置。
- Wednesday, July 18, 2018
- by jfcherng
- Repository
- 1 Watchers
- 0 Stars
- 2 Installations
- PHP
- 0 Dependents
- 0 Suggesters
- 0 Forks
- 0 Open issues
- 6 Versions
- 0 % Grown
php-ip-location
, (*1)
利用 IPIP
和 cz88 (純真)
兩個資料庫來查詢 IP 的地理位置。, (*2)
安裝流程
-
使用 Composer 安裝: composer require jfcherng/php-ip-location
, (*3)
-
這樣就可以了,但如果你想要自己更新 IP 資料庫,請參考以下步驟:, (*4)
- 取得 IPIP.net 的 IP 離線資料庫 (
ipipfree.ipdb
)
- 從 https://www.ipip.net/download.html 下載免費版離線資料庫
(需要登入以及手機驗證,可以免費註冊帳號)
- 純真 IP 資料庫 (
qqwry.dat
) 的 IPDB 格式版本
- 從 https://github.com/metowolf/qqwry.ipdb 下載標準版
- 於使用時自行設定兩個資料庫的路徑
使用方式
見 demo.php
, (*5)
<?php
use Jfcherng\IpLocation\IpLocation;
include __DIR__ . '/vendor/autoload.php';
$ipFinder = IpLocation::getInstance();
// 如果不想要使用內建的 IP 資料庫,請進行以下設定
$ipFinder->setup([
// ipip 資料庫的路徑
'ipipDb' => __DIR__ . '/src/db/ipipfree.ipdb',
// cz88 資料庫的路徑
'cz88Db' => __DIR__ . '/src/db/qqwry.ipdb',
]);
$ip = '202.113.245.255';
$results = $ipFinder->find($ip);
\var_dump($results);
/*
array(5) {
["country_name"]=>
string(6) "中国"
["region_name"]=>
string(6) "天津"
["city_name"]=>
string(6) "天津"
["owner_domain"]=>
string(0) ""
["isp_domain"]=>
string(9) "教育网"
}
*/
dev-master
9999999-dev
利用 IP 查詢地理位置。
Sources
Download
MIT
The Requires
The Development Requires
by
Jack Cherng
1.0.4
1.0.4.0
利用 IP 查詢地理位置。
Sources
Download
MIT
The Requires
The Development Requires
by
Jack Cherng
1.0.3
1.0.3.0
利用 IP 查詢地理位置。
Sources
Download
MIT
The Requires
The Development Requires
by
Jack Cherng
1.0.2
1.0.2.0
利用 IP 查詢地理位置。
Sources
Download
MIT
The Requires
The Development Requires
by
Jack Cherng
1.0.1
1.0.1.0
利用 IP 查詢地理位置。
Sources
Download
MIT
The Requires
The Development Requires
by
Jack Cherng
1.0.0
1.0.0.0
利用 IP 查詢地理位置。
Sources
Download
The Requires
The Development Requires
by
Jack Cherng