ecodenl / lvbag-php-wrapper
LVBAG API 的 PHP 包装器
v2.1.0
2023-02-13 13:52 UTC
Requires
- php: ^7.4.0|^8.0
- guzzlehttp/guzzle: ^6.3.1|^7.4.5
- psr/log: ^1.1.4|^3.0
This package is auto-updated.
Last update: 2024-09-23 15:05:19 UTC
README
IMBAG API (LVBAG) 的简单 PHP 包装器
版本信息
安装
composer require ecodenl/lvbag-php-wrapper
使用 API
阅读官方 API 文档
为了了解可能性和限制,您应该阅读官方 API 文档。
设置连接
use Ecodenl\LvbagPhpWrapper\Client; use Ecodenl\LvbagPhpWrapper\Lvbag; use Ecodenl\LvbagPhpWrapper\Resources\AdresUitgebreid; $secret = 'asecretcodeyouneedtoobtain'; // crs is not static, you should change it accordingly to the desired call. $acceptCRS = 'epsg:28992'; // Establish the connection $client = Client::init($secret, $acceptCRS); // Using the production environment endpoint $shouldUseProductionEndpoint = true; $client = Client::init($secret, $acceptCRS, $shouldUseProductionEndpoint); // To get extensive logging from each request // the client accepts any logger that follows the (PSR-3 standard)[https://github.com/php-fig/log] // This example uses the logger from laravel, but feel free to pass any logger that implements the \Psr\Log\LoggerInterface $logger = \Illuminate\Support\Facades\Log::getLogger(); $client = Client::init($secret, $acceptCRS, $shouldUseProductionEndpoint, $logger); $lvbag = Lvbag::init($client);
资源
详细地址
文档.
基于提供的地址数据。
// Get all available addresses from te given data $addresses = $lvbag->adresUitgebreid() ->list([ 'postcode' => '3255MC', 'huisnummer' => 13, ]); // Only return the exact match $address = $lvbag->adresUitgebreid() ->list([ 'postcode' => '3255MC', 'huisnummer' => 13, 'exacteMatch' => true ]); // Only return the exact match $address = $lvbag->adresUitgebreid() ->list([ 'postcode' => '3255MC', 'huisnummer' => 13, 'huisletter' => 'd', 'exacteMatch' => true, ]);
nummeraanduidingIdentificatie 将从 ->list()
调用中返回,当您需要再次获取属性时(出于任何原因),此调用可能很有用。
$lvbag->adresUitgebreid()->show('1924200000030235');
分页
每个列表方法都将返回分页响应
// return page 2 $addresses = $lvbag->adresUitgebreid() ->page(2) ->list([ 'postcode' => '3255MC', 'huisnummer' => 13, ]); // Its also possible to change the amount per page. $addresses = $lvbag->adresUitgebreid() ->pageSize(12) ->page(2) ->list([ 'postcode' => '3255MC', 'huisnummer' => 13, ]);
居住地
文档.
当调用 adresUitgebreid()
时,地址将包含一个 woonplaatsIdentificatie
。此标识可以用于检索地址所在城市的有关信息
$woonplaatsIdentification = '2134'; $woonplaats = $lvbag->woonplaats()->show($woonplaatsIdentification); // Pass attributes as second parameter to retrieve more info $woonplaats = $lvbag->woonplaats()->show($woonplaatsIdentification, [ // Supports "bronhouders", "geometrie" or "true" (STRING!). "true" returns both. 'expand' => 'bronhouders', ]); // This way one can retrieve the municipality of a city. $woonplaats['_embedded']['bronhouders']
如果不知道标识,您仍然可以调用带有属性的分页列表(分页适用)
$woonplaatsen = $lvbag->woonplaats()->list([ 'naam' => 'Oude-tonge', 'expand' => 'bronhouders', ]);