Forum


Notice to all users

We are migrating towards a new forum system located at community.teamspeak.com, as such this forum will become read-only on January 29, 2020

Results 1 to 4 of 4
  1. #1
    Join Date
    July 2015
    Posts
    2

    [API Teamspeak] number of connected people

    Hi all, I am trying to display the number of connected people and the status of my rental teamspeak server.

    So I find a code that I am trying to make it work but I still receive the answer :

    QueryError: 111 Connection refused
    TS3 Server Status: offline
    Clients online: 0/0

    Here is the code used :

    PHP Code:
    <?php
     
    date_default_timezone_set
    ("Europe/London");
    require_once(
    "libraries/TeamSpeak3/TeamSpeak3.php");
    TeamSpeak3::init();
     
    header('Content-Type: text/html; charset=utf8');
     
    $status "offline";
    $count 0;
    $max 0;
     
    try {
        
    $ts3 TeamSpeak3::factory("serverquery://serveradmin:[email protected]:port-du-teamspeak/?server_port=port-du-serveur&use_offline_as_virtual=1&no_query_clients=1");
        
    $status $ts3->getProperty("virtualserver_status");
        
    $count $ts3->getProperty("virtualserver_clientsonline") - $ts3->getProperty("virtualserver_queryclientsonline");
        
    $max $ts3->getProperty("virtualserver_maxclients");
    }
    catch (
    Exception $e) {
        echo 
    '<div style="background-color:red; color:white; display:block; font-weight:bold;">QueryError: ' $e->getCode() . ' ' $e->getMessage() . '</div>';
    }
    echo 
    '<span class="ts3status">TS3 Server Status: ' $status '</span><br/><span class="ts3_clientcount">Clients online: ' $count '/' $max '</span>';
     
    ?>
    I have received and activate my privilege key.

    Where :
    serveradmin : login coming from the menu "Tools et Query Login"
    mdp : password coming from the menu "Tools et Query Login"
    ip-du-teamspeak : the ip address of my ts server
    port-du-teamspeak : the port of my ts server
    port-du-serveur : the port of the server

    I try the setting with a ts3 viewer script and the connection is a success but with the above code, it is not working

    Any help is welcome

  2. #2
    Join Date
    August 2013
    Location
    Germany
    Posts
    541
    The error "Connection refused" mostly means that the query_port or the query_ip is not right. Ask your hoster if you even should have query access.

  3. #3
    Join Date
    July 2015
    Posts
    2
    Quote Originally Posted by Bluscream View Post
    The error "Connection refused" mostly means that the query_port or the query_ip is not right. Ask your hoster if you even should have query access.
    Ok it is working. I have made mistake and swith server port and iport .

    I am happy

  4. #4
    Join Date
    October 2003
    Location
    Germany
    Posts
    2,527
    If your server appears in the official server list, you can use this simple API to display its status without having to use PHP at all:

    https://www.planetteamspeak.com/rest-api/

    Here's an example on JSFiddle:

    https://jsfiddle.net/wg69b6bd/

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Number of times client has connected
    By Discotex in forum Client Support
    Replies: 2
    Last Post: October 9th, 2012, 09:30 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •