hennio / postcodenlapi
Laravel PostcodeNL API 包
0.3.1
2020-03-04 13:38 UTC
Requires
- guzzlehttp/guzzle: ^6.3
This package is auto-updated.
Last update: 2024-09-04 23:21:54 UTC
README
通过 ServiceProvider 和 Facade 将 PostcodeNL API 与 6 集成。此包目前仅支持荷兰地址的验证。
安装
composer require hennio/postcodenlapi
将 ServiceProvider 添加到 config/app.php
文件中的 providers 数组中
'providers' => [ //other things here Hennio\Postcodenlapi\PostcodenlapiServiceProvider::class, ];
将 facade 添加到 facades 数组中
'aliases' => [ //other things here 'Postcodenlapi' => Hennio\Postcodenlapi\Facades\Postcodenlapi::class, ];
配置
通过 .env 文件
将您的 postcode.nl API 密钥放入 .env 文件中
POSTCODENL_KEY= [...]
POSTCODENL_SECRET= [...]
发布配置
php artisan vendor:publish --provider="Hennio\Postcodenlapi\PostcodenlapiServiceProvider"
或者,在 config/postcodenlapi.php
中设置您的 api key
和 secret
使用方法
要获取与荷兰 postalcode
、housenr
和 extension
相关联的 street
和 city
,响应以 json 格式返回,非常适合ajax。
use Postcodenlapi; $data = Postcodenlapi::validateDutch('1010AA', '1', 'a');