1. Go to this page and download the library: Download postbode/postbode-api 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/ */
postbode / postbode-api example snippets
use Postbode\PostbodeApiClient;
$postbode = new PostbodeApiClient('your-api-key');
foreach ($postbode->mailboxes->list() as $mailbox) {
printf("%s (%s): € %.2f available\n", $mailbox->name, $mailbox->customerCode, $mailbox->balance->available);
}
$postbode = new PostbodeApiClient('your-api-key', new GuzzleHttp\Client(['timeout' => 30]));
use Postbode\Enum\PostalPlex;
use Postbode\Enum\PostalPrinting;
use Postbode\Enum\ShippingType;
use Postbode\Request\PostalRequest;
$request = PostalRequest::make('PSBD', $envelopeUuid)
->addDocumentFromFile(__DIR__ . '/invoice.pdf')
->shipping(ShippingType::NL_FAST)
->printing(PostalPrinting::COLOR)
->plex(PostalPlex::DUPLEX)
->customerReference('INV-1234')
->metadata(['invoice_id' => 1234])
->send();
$postal = $postbode->postals->create($request);
echo $postal->reference; // PSBD-000123
echo $postal->status->name; // Sent
echo $postal->financial->price->amountInclVat;
use Postbode\Enum\PostalStatus;
use Postbode\Enum\ShippingType;
PostalStatus::DELIVERED->value; // 150
PostalStatus::DELIVERED->label(); // 'Delivered'
PostalStatus::DELIVERED->isFinal(); // true
ShippingType::NL_REGISTERED->isTracked(); // true
$postal->status->code; // PostalStatus|null — null if the API added a code we do not know
$postal->status->rawCode; // int — always what the API actually sent
$postal->status->name; // string — the API's own description
use Postbode\Exception\AuthenticationException;
use Postbode\Exception\NotFoundException;
use Postbode\Exception\PostbodeException;
use Postbode\Exception\TransportException;
use Postbode\Exception\ValidationException;
try {
$postbode->postals->create($request);
} catch (ValidationException $e) {
foreach ($e->getErrors() as $field => $messages) {
echo $field, ': ', implode(' ', $messages), PHP_EOL;
}
} catch (AuthenticationException $e) {
// 401 or 403 — bad key, or no access to this mailbox
} catch (NotFoundException $e) {
// 404 — the envelope, mailbox or item does not exist
} catch (TransportException $e) {
// the API could not be reached at all
} catch (PostbodeException $e) {
// anything else, including 400 and 5xx
echo $e->getMessage();
}