munna / iplocation
通过IP地址进行地理定位跟踪。它提供了关于任何国家的更灵活信息。它完全免费且开源。
v1.0.0
2021-02-13 12:57 UTC
This package is auto-updated.
Last update: 2024-09-16 15:05:42 UTC
README
IP定位跟踪
通过IP地址跟踪位置信息。
安装IpLocaiton
接下来,运行Composer命令安装最新稳定版本
composer require munna/iplocation
创建类实例
以创建类实例
// Use this as namespace use Munna\IpLocation\IpLocation; // Set Your Ip Address $ip = "YOUR_IP_ADDRESS"; //this is optional. Find this api key by visiting https://ipinfo.io/account/home?service=google&loginState=create $api_key = "API_TOKEN"; //If you have this api_key $location = new IpLocation($ip, $api_key); // If you do not have this api_key pass only ip $location = new IpLocation($ip); // Finally init the class $location->init();
初始化类实例后,您将获得以下所有数据。
提供的数据
// Get Ip Address $ip = $location->ip; //full info as an array $info = $location->info(); // get region name $region = $location->region; // get country $country = $location->country; // get city name If you set api_key when create instance $cityName = $location->city; // get ioc name $loc = $location->loc; // get postal $postal = $location->postal; // get flag url $flag = $location->flag; // get timeZone $timeZone = $location->timeZone;
所有信息的JSON数据样本
{
"ip": "27.147.201.241",
"hostname": "dhknat-27.147.201.241.link3.net",
"city": "Dhaka",
"country": "BD",
"region": "Dhaka",
"loc": "23.7104,90.4074",
"postal": "1000",
"org": "AS23688 Link3 Technologies Ltd.",
"flag": "https://raw.githubusercontent.com/MunnaAhmed/Flags/main/bd.png"
}
许可证
本软件包为开源,并许可在MIT许可证下。
非常感谢。请给予一颗星。