PHP code example of postbode / postbode-api

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


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

$postbode = new \Postbode\PostbodeClient(API_KEY);
$letters = $postbode->getLetters(MAILBOX_ID);
foreach($letters AS $letter){
    // use $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);
}

$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);
}