zbalh

New Member
Mar 4, 2017
6
0
16
how i can get the client avatar to show it in the website using teamspeak3 framework php
and i used many codes as,

foreach ($ts3_VirtualServer->clientList() as $ts3_Client) { if ($ts3_Client["client_type"] == 0 and $ts3_Client["connection_client_ip"] == getIp()) { function avatarGetName($member) { return new TeamSpeak3_Helper_String("/avatar_" . $member["client_base64HashClientUID"]); } function avatarDownload($member) { $download = $member->getParent()->transferInitDownload(rand(0x0000, 0xFFFF), 0, $member->avatarGetName()); $transfer = TeamSpeak3::factory("filetransfer://" . $download["host"] . ":" . $download["port"]); return $transfer->download($download["ftkey"], $download["size"]); } $client = $ts3_VirtualServer->clientGetByName($ts3_Client); $avatar = avatarDownload($client); header("Content-Type: " . TeamSpeak3_Helper_Convert::imageMimeType($avatar)); echo $avatar; } }

but didn't work just showing me a white blank screen
 

Newcomer1989

Well-Known Member
May 8, 2016
117
90
129
You can have a look here.. It asks the TeamSpeak for a file list at first.

For each file, the TS3 server response, it tries to download it. You needn't to convert the unique client ID at this point, cause it is named inside the file list with that.

But for sure you will need to convert the client unique ID to the base64 unique ID at any point. How to convert this, you will find here at line 53 and following.

In this example you would download the avatar in background as job. So homepage visitor does not need to do that (saves time for siteload), this only opens and display the saved file.

If you want to make it perfect, you will store the avatar with the unique client ID name. Then you would also save the time to convert the unique client ID to the base64 value. If you found out how to do, please share it with me :)
 

fyfywka

TeamSpeak Developer
Contributor
Sep 10, 2015
147
140
158
PHP:
<?php
// load framework files
require_once("libraries/TeamSpeak3/TeamSpeak3.php");
// connect to local server, authenticate and spawn an object for the virtual server on port 9987
$ts3_VirtualServer = TeamSpeak3::factory("serverquery://username:[email protected]:10011/?server_port=9987");
// spawn an object for the client using a specified nickname
$ts3_Client = $ts3_VirtualServer->clientGetByName("John Doe");
// download the clients avatar file
$avatar = $ts3_Client->avatarDownload();
// send header and display image
header("Content-Type: " . TeamSpeak3_Helper_Convert::imageMimeType($avatar));
echo $avatar;
 
Top