Closed emt1803 closed 7 years ago
You didn't select a virtual server.
This only connects you to the server host:
$ts3_ServerInstance = TeamSpeak3::factory("serverquery://username:pswd@domain:10011/");
And when TeamSpeak3::factory()
is called without the server_port
parameter in the query string, it returns an instance of TeamSpeak3_Adapter_ServerQuery
which has no method TeamSpeak3_Adapter_ServerQuery::clientGetByUid()
TeamSpeak3 Hosts can have multiple virtual servers, the default virtual server is 1
and has default voice port 9987
.
You need to add a query string that sets the voice port, this selects the default virtual server, and in turn causes TeamSpeak::factory()
to instead return an instance of TeamSpeak_Node_Server
which is what you're looking for:
$ts3_VirtualInstance = TeamSpeak3::factory("serverquery://username:pswd@domain:10011/?server_port=9987");
(Note: this essentially has the same effect as the Server Query command use 1
)
In your code example, it would look like:
// load framework files
require_once("libs/TeamSpeak3/TeamSpeak3.php");
// connect to local server, authenticate and spawn an object for the server instance
$ts3_ServerInstance = TeamSpeak3::factory("serverquery://username:pswd@domain:10011/?server_port=9987");
$uid = "uid=";
try {
$ts3_ServerInstance->clientGetByUid($uid)->poke("Test!");
}catch (TeamSpeak3_Exception $e){
echo $e;
}
Please make sure to review the documentation, there are several examples of this: https://docs.planetteamspeak.com/ts3/php/framework/index.html#example_sec
Additional References
TeamSpeak3::factory()
https://docs.planetteamspeak.com/ts3/php/framework/class_team_speak3.html#aa0f699eba7225b3a95a99f80b14e73b3
TeamSpeak3_Adapter_ServerQuery
https://docs.planetteamspeak.com/ts3/php/framework/class_team_speak3___adapter___server_query.html
TeamSpeak3_Node_Server
https://docs.planetteamspeak.com/ts3/php/framework/class_team_speak3___node___server.html
Also as UID you need to input UID only, do not add 'uid=' before it!
Closing for inactivity. Please reopen if you need further assistance.
Hello everybody!
I wrote a little script to poke people. But the script throws me a error:
exception 'TeamSpeak3_Node_Exception' with message 'node method 'clientGetByUid()' does not exist' in /var/www/vhosts/url/libs/TeamSpeak3/Node/Abstract.php:381 Stack trace: #0 /var/www/vhosts/url/test.php(10): TeamSpeak3_Node_Abstract->__call('clientGetByUid', Array) #1 /var/www/vhosts/url/test.php(10): TeamSpeak3_Node_Host->clientGetByUid('uid...') #2 {main}
My script is this one:
I hope you can help me.