api.mailbox.org : Beispiele

auth

Request
{
  "jsonrpc":"2.0",
  "method":"auth",
  "params":{
    "user":"test_account",
    "pass":"123456"
  },
  "id":"1"
}
Response bei Erfolg
{
  "jsonrpc":"2.0",
  "result":{
    "session":"LV;N%5TD7)64y&JOpK956fbe591dd89b8.38138624",
    "level":"account"
  },
  "id":"1"
}
Response bei ungültigen Zugangsdaten
{
  "jsonrpc":"2.0",
  "error":{
    "code":2,
    "message":"Zugriff verweigert"
  },
  "id":"1"
}

PHP-API-Client:

<?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_message();
} else {
	echo $r['session'];
}

 

deauth

Request mit gültiger Auth-ID im HTTP-Header
{
  "jsonrpc":"2.0",
  "id":"1",
  "method":"deauth",
  "params":""
}
Response
{
  "jsonrpc":"2.0",
  "result":true,
  "id":"1"
}

PHP-API-Client:

<?php
require_once './api.mailbox.org.client.php';
 
// assuming Auth-ID in some $_SESSION variable
$session = $_SESSION['api_auth_id'];
 
$api = new api_mailbox_org_client($session);
$r = $api->call('deauth');
if ($r === FALSE) {
    echo $api->error_code().': '.$api->error_message();
} else {
	echo 'success';
}

hello.world

Request
{
  "jsonrpc":"2.0",
  "id":"1",
  "method":"hello.world",
  "params":""
}
Response
{
  "jsonrpc":"2.0",
  "result":"Hello World!",
  "id":"1"
}

hello.innerworld

Request mit gültiger Auth-ID im HTTP-Header
{
  "jsonrpc":"2.0",
  "id":"1",
  "method":"hello.innerworld",
  "params":""
}
Response
{
  "jsonrpc":"2.0",
  "result":"Hello Inner-World!",
  "id":"1"
}

 

domain.list

Request mit gültiger Auth-ID im HTTP-Header
{
  "jsonrpc":"2.0",
  "id":"1",
  "method":"domain.list",
  "params":{
      "account":"test_account"
  }
}
Response
{
  "jsonrpc":"2.0",
  "result":[
    {
      "domain":"domain1.test",
      "count_mails":2
    },
    {
      "domain":"domain2.test",
      "count_mails":0
    },
    {
      "domain":"domain3.test",
      "count_mails":33
    },
    {
      "domain":"domain4.test",
      "count_mails":0
    }
  ],
  "id":"1"
}