thisliu/easyip

此处为包描述。

维护者

详细信息

github.com/thisliu/ip

源代码

2.0.0 2019-04-21 01:31 UTC

This package is not auto-updated.

Last update: 2024-09-21 18:06:44 UTC


README

IP SDK.

StyleCI build status

安装

$ composer require thisliu/easyip -vvv

介绍

目前支持 5 家平台

使用

$config = [
    'provider' => 'tencent',
    'tencent' => [
        'key' => '',
    ],
    
    ...
    ...
    ...
];

$ip = new \Icecho\EasyIp\EasyIp($config);

$result = $ip->parse('');

在 Laravel 中使用

php artisan vendor:publish --provider="Icecho\EasyIp\ServiceProvider"

进入 config/easyip.php

return [
    'provider' => 'tencent',


    'tencent' => [
        'key' => '',
    ],
    
    ...
    ...
    ...
]

在 tinker 中测试

app('EasyIp')->parse('')

...
...

数据返回格式

# 如果想要 api 原生格式,在 config/easyip.php 中,把 format 改为 false

[
     "provider" => "Tencent",
     "ip" => "",
     "postcode" => 440300,
     "country" => "中国",
     "province" => "广东省",
     "city" => "深圳市",
     "district" => "南山区",
     "implode" => "中国广东省深圳市南山区",
     "location" => [
       "latitude" => 22.55329,
       "longitude" => 113.88308,
     ],
]

许可证

MIT