faicchia/laravel-nationalize
最新稳定版本:1.0.0
Composer 安装命令:
composer require faicchia/laravel-nationalize
包简介
A service wrapper around nationalize.io
README 文档
README
A service wrapper around nationalize.io
Installation
composer require faicchia/laravel-nationalize
The package will automatically register itself.
Configuration
If you wish to edit the package configuration, you can run the following command to publish it into your config/ folder:
php artisan vendor:publish --provider="Faicchia\Nationalize\NationalizeServiceProvider"
Environment
If you purchased an API Key, add the following line to your .env file
NATIONALIZE_API_KEY=...
Usage
Single name
$response = Nationalize::name('Michael')->get() print $response->status // 200 - HTTP response code print $response->limit // 1000 - The amount of names available in the current time window print $response->remaining // 728 - The number of names left in the current time window print $response->reset // 15281 - Seconds remaining until a new time window opens print $response->error // null - Error string print $response->result->name // Michael print $response->result->countries // [ // "US" => 0.08986482266532715, // "AU" => 0.05976757527083082, // "NZ" => 0.04666974820852911 // ]
Multiple names
$response = Nationalize::name(['Michael', 'Kevin'])->get() // or $response = Nationalize::names(['Michael', 'Kevin'])->get() foreach ($response->result as $prediction) { print $prediction->name print $prediction->countries }
Error
// e.g. Invalid API Key $response = Nationalize::name('Michael')->get() print $response->status // 401 print $response->error // "Invalid API key"
统计信息
- 总下载量: 16
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-07-20