/**
  * Return the list of the channels in the server
  * @param $ts3 Ts3ServerQuery
  * @return array
  * @throws Exception
  */
 public static function getChannels($ts3)
 {
     $result = $ts3->sendCommand('channellist');
     if ($ts3->getLastError() != 0) {
         throw new Exception('Cannot get channels');
     }
     $channels = explode('|', $result);
     $result = array();
     foreach ($channels as $raw_user) {
         $channel = Ts3ServerQuery::explodeProperties($raw_user);
         $channel['channel_name'] = RealtimeChannels::formatName($channel['channel_name']);
         $result[] = $channel;
     }
     return $result;
 }
<?php

require_once __DIR__ . '/../API.php';
API::init();
if (!Config::get("realtime.enabled")) {
    http_response_code(403);
    API::printJSON(array('error' => 'Realtime disabled'));
}
try {
    $ts3 = new Ts3ServerQuery(Config::get("realtime.host"), Config::get("realtime.port", 10011), Config::get("realtime.username", "serveradmin"), Config::get("realtime.password"));
    $users = RealtimeUsers::getOnlineUsers($ts3);
    $channels = RealtimeChannels::getChannels($ts3);
} catch (Exception $e) {
    http_response_code(500);
    API::printJSON(array('error' => 'Boh...'));
}
API::printJSON(RealtimeFormatter::getRealtime($users, $channels));