IP SDK.
$ composer require icecho/easyip -vvv
目前支持 5 家平台
$config = [
'provider' => 'tencent',
'tencent' => [
'key' => '',
],
...
...
...
];
$ip = new \Icecho\EasyIp\EasyIp($config);
$result = $ip->parse('');
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