weha / bpost-addresses

Bpost地址验证API的PHP类

0.1.9 2024-04-17 08:33 UTC

This package is auto-updated.

Last update: 2024-09-17 09:28:20 UTC


README

Bpost地址验证API的PHP类

bpost比利时邮政集团)提供了一个API来验证比利时地址:[https://www.bpost.be/site/en/webservice-address](https://www.bpost.be/site/en/webservice-address)。

此工具的目的是帮助使用PHP轻松查询bpost API。

安装

此工具仅需要PHP 7.0+和guzzlehttp/guzzle。

通过composer + packagist使用:[https://packagist.org.cn/packages/ici-brussels/bpost-addresses](https://packagist.org.cn/packages/ici-brussels/bpost-addresses)

用法

$bpost = new Bpost_Address_Validation();

// Find relevant address according to input
/* Option 1: Structured */
$bpost->getAddress_Structured("Rue de la loix", "15", null, 1000, "Bruxelles");
/* Option 2: Unstructured */
$bpost->getAddress_Unstructured("rue de la loi 15, 1000 bruxelles");

// get array with validated address
$result = $bpost->getStructuredAddress();
print_r($result);
/*
Array
(
    [StreetName] => Rue De La Loi
    [StreetNumber] => 15
    [BoxNumber] => 
    [PostalCode] => 1040
    [MunicipalityName] => Bruxelles
    [CountryName] => Belgique
)
*/

// get array with latitude/longitude
$result = $bpost->getGeographicalLocation();
print_r($result);
/*
Array
(
    [lat] => 50.845465
    [lon] => 4.369107
)
*/

鸣谢