postnummersok / client
API client for PostnummerSök.
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: 2025-06-24 07:28:19 UTC
README
This is an API Client for communicating with PostnummerSök using PHP.
Use With Composer
(We will just assume you have composer installed for your project)
-
Open a command-line interface and navigate to your project folder.
-
Run the following command in your command-line interface:
composer require postnummersok/client:dev-master
Composer will now autoload Client.php when you create the class object:
$postnummersok = new PostnummerSok\Client();
Use Without Composer
Manually include Client.php in your script before initiating the client.
require_once 'path/to/Client.php';
$postnummersok = new PostnummerSok\Client();
Example Code (More examples in the examples/ folder)
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());
}