api.mailbox.org : PHP API client

Download

The latest version of the client code is available for download at the following URL:

https://api.mailbox.org/v1/client

Setup

Copy the downloaded client file to an appropriate location within your software project. Afterwards, enter
the location path into the PHP code as follows:

<?php
require_once './api.mailbox.org.client.php';

When creating a new client instance, the constructor may contain an Auth-ID (for authenticated requests)
or no value (anonymous requests):

// anonymous Requests
$api = new api_mailbox_org_client();
// authenticated requests
 
// Assume the ID is in $_SESSION
$auth_id = $_SESSION['api_auth_id'];
$api = new api_mailbox_org_client($auth_id);

Now it is possible to execute methods. Please refer to the API documentation for details.

Examples

hello.world (anonymous request)

<?php
require_once './api.mailbox.org.client.php';
$api = new api_mailbox_org_client();
$r = $api->call('hello.world');
if ($r === FALSE) {
	echo 'API ERROR! Code: '.$api->error_code().', Message: '.$api->error_message();
} else {
    // "Hello World!"
	echo $r;
}

 

Request Auth-ID (anonymous request)

<?php
require_once './api.mailbox.org.client.php';
$api = new api_mailbox_org_client();
 

$params = array(
    'user' => 'test_account',
    'pass' => '123456'
);
$r = $api->call('auth', $params);
if ($r === FALSE) {
	echo 'API ERROR! Code: '.$api->error_code().', Message: '.$api->error_message();
} else {
    $_SESSION['api_auth_id'] = $r['session'];
}

 

domain.list with valid Auth-ID (authenticated request)

<?php
require_once './api.mailbox.org.client.php';
 

// Assume the ID is in $_SESSION
$auth_id = $_SESSION['api_auth_id'];
$api = new api_mailbox_org_client($auth_id);
 

$params = array(
    'account' => 'test_account',
);
$r = $api->call('domain.list', $params);
if ($r === FALSE) {
	echo 'API ERROR! Code: '.$api->error_code().', Message: '.$api->error_message();
} else {
    foreach ($r AS $item) {
        echo 'Domain: '.$item['domain'].', Anzahl Mailadressen: '.$item['count_mails'].PHP_EOL;
    }
}