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 :
I have received and activate my privilege key.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>';
?>
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