ok/ipstack-client
Composer 安装命令:
composer require ok/ipstack-client
包简介
A PHP wrapper for using Ipstack API
README 文档
README
ipstack-client
A PHP wrapper for using Ipstack API
Install via composer:
composer require ok/ipstack-client
Basic usage
Get data as the Location object:
$client = new OK\Ipstack\Client('api_key'); $location = $client->get('134.201.250.155', false); var_dump($location);
result:
class OK\Ipstack\Entity\Location#3 (12) { protected $city => string(11) "Los Angeles" protected $continentCode => string(2) "NA" protected $continentName => string(13) "North America" protected $countryCode => string(2) "US" protected $countryName => string(13) "United States" protected $regionCode => string(2) "CA" protected $regionName => string(10) "California" protected $zip => string(5) "90026" protected $latitude => double(34.0766) protected $longitude => double(-118.2646) protected $ip => string(15) "134.201.250.155" protected $valid => bool(true) }
Get data as a simple array:
$client = new OK\Ipstack\Client('api_key'); $location = $client->get('134.201.250.155'); var_dump($location);
result:
array(13) { 'ip' => string(15) "134.201.250.155" 'type' => string(4) "ipv4" 'continent_code' => string(2) "NA" 'continent_name' => string(13) "North America" 'country_code' => string(2) "US" 'country_name' => string(13) "United States" 'region_code' => string(2) "CA" 'region_name' => string(10) "California" 'city' => string(11) "Los Angeles" 'zip' => string(5) "90026" 'latitude' => string(7) "34.0766" 'longitude' => string(9) "-118.2646" 'location' => array(8) { 'geoname_id' => string(7) "5368361" 'capital' => string(15) "Washington D.C." 'languages' => array(3) { 'code' => string(2) "en" 'name' => string(7) "English" 'native' => string(7) "English" } 'country_flag' => string(38) "http://assets.ipstack.com/flags/us.svg" 'country_flag_emoji' => string(8) "🇺🇸" 'country_flag_emoji_unicode' => string(15) "U+1F1FA U+1F1F8" 'calling_code' => string(1) "1" 'is_eu' => array(0) { } } }
Information
Modifiable output params
Available params for getting custom result
For example:
$client = new OK\Ipstack\Client('api_key'); $client->getParams()->addField("calling_code");
Data providers
Now, here are available several providers:
You can change provider by pass one of type above as second argument in constructor
For example:
$client = new OK\Ipstack\Client('api_key', OK\Ipstack\Provider\ProviderFactory::TYPE_IPAPI);
ok/ipstack-client 适用场景与选型建议
ok/ipstack-client 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 394.99k 次下载、GitHub Stars 达 10, 最近一次更新时间为 2018 年 06 月 29 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「api」 「client」 「IP」 「geocode」 「ipstack」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 ok/ipstack-client 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 ok/ipstack-client 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 ok/ipstack-client 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A PSR-7 compatible library for making CRUD API endpoints
Mock PSR-18 HTTP client
Asynchronous MQTT client built on React
Client for Google Directions API to add interpolated points to a route consisting of given coordinates.
Alfabank REST API integration
A Flickr wrapper to allow you to call the Flickr api with Guzzle as the backend.Goal is to have 100% Flickr api coverage rather than just upload/display photos (currently at 23%).
统计信息
- 总下载量: 394.99k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 11
- 点击次数: 22
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-06-29