postnummersok / client
PostnummerSök的API客户端
dev-master
2019-09-23 19:28 UTC
Requires
- php: >=5.4
Requires (Dev)
- phpunit/phpunit: ^7.0
This package is auto-updated.
Last update: 2024-09-24 05:51:09 UTC
README
这是一个使用PHP与PostnummerSök通信的API客户端。
与Composer一起使用
(我们假设您已经为您的项目安装了composer)
-
打开命令行界面并导航到您的项目文件夹。
-
在命令行界面中运行以下命令
composer require postnummersok/client:dev-master
Composer将在您创建类对象时自动加载Client.php
$postnummersok = new PostnummerSok\Client();
不使用Composer使用
在初始化客户端之前,手动将Client.php包含到您的脚本中。
require_once 'path/to/Client.php';
$postnummersok = new PostnummerSok\Client();
示例代码(更多示例在examples/文件夹中)
require_once 'path/to/Client.php';
try {
$postnummersok = new PostnummerSok\Client();
$postnummersok->setCustomerId(12345)
->setApiKey('0123456789abcdef0123456789abcdef');
$request = [
'postcode' => '11122',
'country_code' => 'SE',
];
$result = $postnummersok->Lookup($request);
} catch(Exception $e) {
die('An error occured: '. $e->getMessage() . PHP_EOL . PHP_EOL
. $postnummersok->getLastLog());
}