Teamspeak 3 PHP Framework Client ID

1.7k views Asked by At

I'm searching the whole day and can't find how I get the Client ID if I just have the Teamspeak Name from the User.

My current code (just works with the Identity ID):

function tsverification($verification) {
        require_once("../ts3phpframework-master/libraries/TeamSpeak3/TeamSpeak3.php");
        $ts3_VirtualServer = TeamSpeak3::factory("serverquery://serveradmin:[email protected]:10011/?server_port=9987&nickname=Poker");
        $client = $ts3_VirtualServer->clientGetByUid("$verification");
        $ts3_VirtualServer->clientPoke($client, "Poke Message");
}
3

There are 3 answers

0
pankapuzza On

I tried this method and it works

<?php
    $msg = $_POST['msg'];
    $client = $_POST['client'];

    require_once("TeamSpeak3/libraries/TeamSpeak3/TeamSpeak3.php");

    $ts3_VirtualServer = TeamSpeak3::factory("serverquery://serveradmin:PASSWORD@IPADDRESS:PORT/?server_port=9987&nickname=USG-Staff");

    $ts3_VirtualServer->clientGetByName("$client")->poke("$msg");
?>
0
Schrotty On

You can use the getUniqueId() function, which will return a unique id. See offical docs: https://docs.planetteamspeak.com/ts3/php/framework/class_team_speak3___node___client.html#a55de8c3f5abcf4794b72a1bc464c2cb4

function getUserID($sUsername){
    TeamSpeak3::init();
    $oTeamSpeak = TeamSpeak3::factory('serverquery://' . Config::$sQueryName . ':' . Config::$sQueryPasswd . '@' . Config::$sServerIP . ':' . Config::$sQueryPort . '/?server_port=' . Config::$sServerPort . '');

    $oClient = $oTeamSpeak->clientGetByName($sUsername);

    return $oClient->getUniqueId();
}
0
luguhe On

I found a solution by myself:

function tsverification($verification) {
    require_once("../ts3phpframework-master/libraries/TeamSpeak3/TeamSpeak3.php");
    $ts3_VirtualServer = TeamSpeak3::factory("serverquery://serveradmin:[email protected]:10011/?server_port=9987&nickname=Poker");

    if (substr($verification, -1, 1) == "=" && strlen($verification) == 28) { // Via UID
        $client = $ts3_VirtualServer->clientGetByUid("$verification");
        $ts3_VirtualServer->clientPoke($client, "Poker poked you.");
    } else { // Via Teamspeak Name
        $ts3_VirtualServer->clientGetByName("$verification")->poke("Poker poked you."); 
    }
}