1

如果我只有用户的 Teamspeak 名称,我整天都在搜索,但找不到如何获取客户端 ID。

我当前的代码(仅适用于身份 ID):

function tsverification($verification) {
        require_once("../ts3phpframework-master/libraries/TeamSpeak3/TeamSpeak3.php");
        $ts3_VirtualServer = TeamSpeak3::factory("serverquery://serveradmin:XXXXXX@XXX.XXX.XXX.XX:10011/?server_port=9987&nickname=Poker");
        $client = $ts3_VirtualServer->clientGetByUid("$verification");
        $ts3_VirtualServer->clientPoke($client, "Poke Message");
}
4

3 回答 3

0

我试过这个方法,它有效

<?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");
?>
于 2016-12-24T15:23:59.660 回答
0

您可以使用 getUniqueId() 函数,该函数将返回一个唯一 ID。请参阅官方文档: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();
}
于 2016-10-02T09:53:08.830 回答
0

我自己找到了解决方案:

function tsverification($verification) {
    require_once("../ts3phpframework-master/libraries/TeamSpeak3/TeamSpeak3.php");
    $ts3_VirtualServer = TeamSpeak3::factory("serverquery://serveradmin:XXXXXX@XXX.XXX.XXX.XX: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."); 
    }
}
于 2016-08-29T19:42:28.950 回答