need help..!

gameover16

Member
Jul 6, 2016
16
0
51
Wrong Thread Title
i need get user avatar in ts3 server from php but i get error
PHP:
<?php
// load framework files
require_once("libraries/TeamSpeak3/TeamSpeak3.php");

// connect and get server object 
$serverObj = TeamSpeak3::factory("serverquery://serveradmin:[email protected]:10011/?server_port=9987"); 

// grab first matching id for given nickname and query db info 
$clientDbid = current($serverObj->clientFindDb("123")); 
$clientInfo = $serverObj->clientInfoDb($clientDbid); 

// init a file transfer for the client avatar using random transfer id   
$download = $node->transferInitDownload(rand(0x0000, 0xFFFF), 0, "/avatar_" . $clientInfo["client_base64HashClientUID"]); 
$transfer = TeamSpeak3::factory("filetransfer://" . $download["host"] . ":" . $download["port"]); 

// download the avatar data 
$avatar = $transfer->download($download["ftkey"], $download["size"]); 

// send header and display image 
header("Content-Type: " . TeamSpeak3_Helper_Convert::imageMimeType($avatar)); 
?>

error
HTML:
Notice: Undefined variable: node in /opt/lampp/htdocs/ts3/index.php on line 13

Fatal error: Call to a member function transferInitDownload() on a non-object in /opt/lampp/htdocs/ts3/index.php on line 13
 

Najsr

Moderator
TeamSpeak Developer
Apr 23, 2016
483
249
167
Try something like this.
PHP:
<?php
// load framework files
require_once("libraries/TeamSpeak3/TeamSpeak3.php");

// connect and get server object
$serverObj = TeamSpeak3::factory("serverquery://serveradmin:[email protected]:10011/?server_port=9987");

// grab first matching id for given nickname and query db info
$client = $serverObj->clientGetByDbid("123");

$avatar = $client->avatarDownload();
?>
But you need to figure out how to display the image (Coz I don't know it yet :()
 

freets3.ovh

Active Member
Sep 19, 2015
150
105
85
Im use this me on my panel :

PHP:
avatar.php

<?php
    $name = htmlspecialchars($_GET["name"]);
       require_once("settings.php");
    require_once("libraries/TeamSpeak3/TeamSpeak3.php");
    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"]);
    }
    $ts3 = TeamSpeak3::factory("serverquery://serveradmin:$login_password@$ip:$query_port/?server_port=$virtualserver_port");
    $client = $ts3->clientGetByName($name);
    $avatar = avatarDownload($client);
    header("Content-Type: " . TeamSpeak3_Helper_Convert::imageMimeType($avatar));
    echo $avatar;
?>
Example : http://v3.freets3.ovh/vip/demo/avatar.php?name=Freets3.ovh Admin Kevin
 

Umar

Member
Jun 18, 2016
65
8
40
Im use this me on my panel :

PHP:
avatar.php

<?php
    $name = htmlspecialchars($_GET["name"]);
       require_once("settings.php");
    require_once("libraries/TeamSpeak3/TeamSpeak3.php");
    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"]);
    }
    $ts3 = TeamSpeak3::factory("serverquery://serveradmin:$login_password@$ip:$query_port/?server_port=$virtualserver_port");
    $client = $ts3->clientGetByName($name);
    $avatar = avatarDownload($client);
    header("Content-Type: " . TeamSpeak3_Helper_Convert::imageMimeType($avatar));
    echo $avatar;
?>
Example : http://v3.freets3.ovh/vip/demo/avatar.php?name=Freets3.ovh Admin Kevin
can u give me the file : settings.php
also the link you send it doesn't work ><
 

Umar

Member
Jun 18, 2016
65
8
40
i find this in the internet

PHP:
<?php
    //Teamspeak Connection IP
    $config['teamspeak']['ip'] = TS3 IP';   
    //Teamspeak Query Port
    $config['teamspeak']['queryport'] = '10011';
    //Teamspeak Connection Port
    $config['teamspeak']['serverport'] = '9987';   
    //Teamspeak Query Login Name
    $config['teamspeak']['loginname'] = 'serveradmin';
    //Teamspeak Query Password
    $config['teamspeak']['loginpass'] = '';           
    //Teamspeak Display Name !
    $config['teamspeak']['displayname'] = 'TS3-Avatar-Bot';
 
    require_once('libraries/TeamSpeak3/TeamSpeak3.php');
    TeamSpeak3::init();
    foreach ($ts3->clientList() as $client) {
        try {
            $data = $client->avatarDownload();
            $file = fopen('/avatar/'.$client->client_database_id, 'w+');
            fwrite($file, $data);
            fclose($file);
        } catch (TeamSpeak3_Exception $e) {
        }
    }
 
?>

can u check this codes?
anything wrong ?
sorry for my bad english :D
 
Last edited:
Top