hpolthof/postcode-tech

使用postcode.tech轻松查找荷兰邮政编码的库

v1.0.3 2021-05-01 13:43 UTC

This package is auto-updated.

Last update: 2024-09-29 05:48:45 UTC


README

Build Status

这是一个围绕Postcode.Tech API的包装器。您需要此API的API密钥才能使用。您可以免费注册并创建API密钥。

安装

要安装,请使用composer

composer require hpolthof/postcode-tech

用法

请参阅以下示例以了解用法

use Hpolthof\PostcodeTech\Exceptions\HttpException;
use Hpolthof\PostcodeTech\Exceptions\PostcodeNotFoundException;
use Hpolthof\PostcodeTech\Exceptions\ValidationException;
use Hpolthof\PostcodeTech\Postcode;

$apiKey = '';

try {
    $postcode = Postcode::search('1071BM', 29, $apiKey);
    echo $postcode->street(); // result: "Pieter Cornelisz. Hooftstraat"
    echo $postcode->city(); // result: "Amsterdam"
} catch (PostcodeNotFoundException $exception) {
    echo "Postcode was not found.";
} catch (ValidationException $exception) {
    echo "No valid lookup query was provided.";
} catch (HttpException $exception) {
    echo "Something else went wrong on the server side.";
} catch (Exception $exception) {
    echo "Something went wrong in this application. Crap!";
}

免责声明

本软件包可免费使用。当然,该软件提供“原样”,并且没有任何保证。

如果您喜欢这个软件包,如果您能留下一条感谢的信息,将非常感激!;-)

该软件包由以下人员构建:Paul Olthof