Get Ip Info API
Yii2 Ip 归属地查询, (*1)
现整合了淘宝,腾讯,新浪三个查询API接口,后期会增加其他接口, (*2)
安装步骤:, (*3)
1、下载安装, (*4)
$ php composer.phar require mrfeng/ipinfo "*"
或者在composer.json中添加一下配置, (*5)
mrfeng/ipinfo "*"
然后运行, (*6)
composer update
2、配置, (*7)
return [ 'components' => [ 'ipinfo' => [ // 淘宝API 'class' => 'mrfeng\ipinfo\TaoBaoIpInfo', ] ], ];
或, (*8)
return [ 'components' => [ 'ipinfo' => [ // 腾讯API 'class' => 'mrfeng\ipinfo\QQIpInfo', ] ], ];
或, (*9)
return [ 'components' => [ 'ipinfo' => [ // SINA API 'class' => 'mrfeng\ipinfo\SinaIpInfo', ] ], ];
3、应用, (*10)
Yii::$app->ipinfo->getinfo('127.0.0.1');//查询指定的IP地址
会返回一个IP归属地的字符串, (*11)