phalcon-plugins/ip-data
Composer 安装命令:
composer require phalcon-plugins/ip-data
包简介
Allows lookup the location of any IP address
README 文档
README
Plugin allows lookup the location of any IP address
website
link to documentation
How to use
- As a shared service from json file
Create file in json format and save in desired folder
{
"sharedServices": {
"ipdata": {
"className": "\\PhalconPlugins\\IpData",
"properties": [
{
"name": "apiKey",
"value": {
"type": "parameter",
"value": "your-ip-data-api-key"
}
},
{
"name": "baseUrl",
"value": {
"type": "parameter",
"value": "https://api.ipdata.co"
}
}
]
}
}
}
In your application read the file with Phalcon Json adatper an Load as a shared service
$sharedServices = new Phalcon\Config\Adapter\Json('path-to-json-file-with-shared-services');
foreach ($sharedServices->path('sharedServices', []) as $shareName => $options) {
$di->setShared($shareName, $options->toArray());
};
Call anywere in your application ( controllers or plugins )
$ipdata = $this->ipdata->locate('ip-address-to-locate');
- As a instance of class
$ipdata = new PhalconPlugins\IpData();
$ipdata->setApiKey('your-api-key');
$ipdata->setBaseUrl('https://api.ipdata.co');
$data = $ipdata->locate('ip-address-to-locate');
统计信息
- 总下载量: 57
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 2
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-04-03