Skip to content

postbode/postbode-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Postbode.nu API

Getting started

Initialize composer package

composer require postbode/postbode-api

Complete documentation

Our complete API is available at https://api.postbode.nu

Usage

List all available mailboxes

$postbode = new \Postbode\PostbodeClient(API_KEY);
$mailboxes = $postbode->getMailboxes();
foreach($mailboxes AS $mailbox){
    // use $mailbox
}

List all letters in mailbox

$postbode = new \Postbode\PostbodeClient(API_KEY);
$letters = $postbode->getLetters(MAILBOX_ID);
foreach($letters AS $letter){
    // use $letter
}

Send letter

$postbode = new \Postbode\PostbodeClient(API_KEY);

$filename = 'example.pdf';
$envelope_id = 2;
$country = 'NL';
$registered = false; // Registered letter
$send_direct = false; // Create concept in mailbox

$letter = $postbode->sendLetter(MAILBOX_ID, $filename, $envelope_id, $country, $registered, $send_direct);
if(!is_array($letter)){
    echo 'Failed! Errorcode: '.$letter;
}else{
    echo 'Letter sent!';
    echo '<br /><pre>';
    print_r($letter);
}

Add letters to queue and send in one request

$postbode = new \Postbode\PostbodeClient(API_KEY);

$envelope_id = 2;
$country = 'NL';
$registered = false; // Registered letter
$send_direct = false; // Create concept in mailbox

$postbode->addLetterToQueue(MAILBOX_ID, 'Letter_A.pdf', $envelope_id, $country, $registered, $send_direct);
$postbode->addLetterToQueue(MAILBOX_ID, 'Letter_B.pdf', $envelope_id, $country, $registered, $send_direct);
$postbode->sendLetterQueue();

if(!is_array($letter)){
    echo 'Failed! Errorcode: '.$letter;
}else{
    echo 'Letter sent!';
    echo '<br /><pre>';
    print_r($letter);
}