tenfef / ipfind-php
用于从IP地址获取位置信息的PHP库
1.0.1
2016-11-05 11:21 UTC
This package is not auto-updated.
Last update: 2024-09-28 20:08:59 UTC
README
一个简单的类,用于从用户的IP地址获取其位置。该类使用IP Find - IP地理位置API作为该服务的后端API。
安装
使用以下命令安装最新版本
$ composer require tenfef/ipfind-php
基本用法
<?php use Tenfef\IPFind\IPFind; $apiKey = "YOUR_API_KEY_HERE"; // get an API key from https://ipfind.co or pass in NULL if you plan on using < 100/day $ipfind = new IPFind($apiKey); $result = $ipfind->fetchIPAddress('8.8.8.8'); var_dump($result); /* object(stdClass)#2 (14) { ["ip_address"]=> string(7) "8.8.8.8" ["country"]=> string(13) "United States" ["country_code"]=> string(2) "US" ["continent"]=> string(13) "North America" ["continent_code"]=> string(2) "NA" ["city"]=> string(13) "Mountain View" ["county"]=> string(11) "Santa Clara/ ["region"]=> string(10) "California" ["region_code"]=> string(2) "CA" ["timezone"]=> string(3) "PST" ["owner"]=> string(26) "LEVEL 3 COMMUNICATIONS INC" ["longitude"]=> float(-122.0865) ["latitude"]=> float(37.3801) ["warning"]=> string(131) "You are not using an IP Find API Key. You are limited to 100 requests/day. Register for free at https://ipfind.co for higher limits" } */
文档
许可证
IP Find采用MIT许可证授权