PHP code example of deutschepost / sdk-api-addressfactory
1. Go to this page and download the library: Download deutschepost/sdk-api-addressfactory library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
deutschepost / sdk-api-addressfactory example snippets
$logger = new \Psr\Log\NullLogger();
$configName = 'default';
$serviceFactory = new \PostDirekt\Sdk\AddressfactoryDirect\Service\ServiceFactory();
$service = $serviceFactory->createAddressVerificationService('user', 'pass', $logger);
$record = $service->getRecordByAddress('53114', 'Bonn', 'Sträßchenweg', '10', 'Mustermann', 'Hans', null, $configName);
echo $record->getAddress()->getPostalCode(); // "53113"
echo $record->getAddress()->getStreetName(); // "Sträßchensweg"
echo $record->getStatusCodes(); // ['BAC100103', 'FNC400501', 'PDC030105', '…']
$logger = new \Psr\Log\NullLogger();
$configName = 'default';
$serviceFactory = new \PostDirekt\Sdk\AddressfactoryDirect\Service\ServiceFactory();
$service = $serviceFactory->createAddressVerificationService('user', 'pass', $logger);
$requestBuilder = new \PostDirekt\Sdk\AddressfactoryDirect\RequestBuilder\RequestBuilder();
$requestBuilder->setMetadata($recordId = 1);
$requestBuilder->setAddress('Deutschland', '53114', 'Bonn', 'Sträßchenweg', '10');
$request = $requestBuilder->create();
$records = $service->getRecords([$request], null, $configName);
foreach ($records as $record) {
echo $record->getRecordId(); // 1
echo $record->getAddress()->getPostalCode(); // "53113"
echo $record->getAddress()->getStreetName(); // "Sträßchensweg"
echo $record->getStatusCodes(); // ['BAC100103', 'FNC400501', 'PDC030105', '…']
}