Skip to content

Commit a35fa73

Browse files
committed
update doc
1 parent f464b51 commit a35fa73

2 files changed

Lines changed: 13 additions & 15 deletions

File tree

README.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,21 @@ composer require 'itbdw/ip-database'
2727

2828
use itbdw\Ip\IpLocation;
2929

30-
$hostname = 'itbdw.com';
31-
$ip = gethostbyname($hostname);
32-
33-
echo $hostname . "\n";
30+
$ip = '140.205.172.5'; //阿里云官网 ip
31+
echo json_encode(IpLocation::getLocation($ip), JSON_UNESCAPED_UNICODE) . "\n";
32+
//{"ip":"140.205.172.5","country":"中国","province":"浙江","city":"杭州市","county":"","isp":"","area":"中国浙江杭州市阿里巴巴网络有限公司BGP数据中心"}
3433

34+
$ip = '172.217.27.142';//Google Ip
3535
echo json_encode(IpLocation::getLocation($ip), JSON_UNESCAPED_UNICODE) . "\n";
36-
```
36+
//{"ip":"172.217.27.142","country":"美国","province":"","city":"","county":"","isp":"","area":"美国加利福尼亚州圣克拉拉县山景市谷歌公司"}
37+
3738

38-
## 测试合法性
3939

4040
```
41-
➜ php tests/ip.php
42-
qq.com
43-
```
44-
正确数据
41+
42+
## 响应
43+
44+
获取成功
4545
```json
4646
{
4747
"ip": "163.177.65.160",
@@ -54,7 +54,7 @@ qq.com
5454
}
5555
```
5656

57-
异常情况
57+
异常
5858
```json
5959
{
6060
"error": "ip invalid"

tests/ip.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,10 @@
1010
use itbdw\Ip\IpLocation;
1111

1212
$hostnames = [
13-
'baidu.com',
14-
'immomo.com',
15-
'github.com',
1613
'aliyun.com',
1714
'google.com',
18-
'weibo.com'
15+
'weibo.com',
16+
'invalidip',
1917
];
2018
shuffle($hostnames);
2119
$hostname = array_pop($hostnames);

0 commit comments

Comments
 (0)