Forum


Notice to all users

We are migrating towards a new forum system located at community.teamspeak.com, as such this forum will become read-only on January 29, 2020

Page 67 of 100 FirstFirst ... 1757656667686977 ... LastLast
Results 991 to 1,005 of 1498
  1. #991
    Join Date
    September 2014
    Posts
    6
    Im having some errors when trying to reply to the user using this code

    // load framework files
    require_once("libraries/TeamSpeak3/TeamSpeak3.php");
    // connect to local server in non-blocking mode, authenticate and spawn an object for the virtual server on port 9987
    $ts3_VirtualServer = TeamSpeak3::factory("serverquery://username[email protected]:10011/?server_port=9987&blocking=0");
    // get notified on incoming private messages
    $ts3_VirtualServer->notifyRegister("textprivate");
    // register a callback for notifyTextmessage events
    TeamSpeak3_Helper_Signal::getInstance()->subscribe("notifyTextmessage", "onTextmessage");
    // wait for events
    while(1) $ts3_VirtualServer->getAdapter()->wait();
    // define a callback function
    function onTextmessage(TeamSpeak3_Adapter_ServerQuery_Event $event, TeamSpeak3_Node_Host $host)
    {
    echo "Client " . $event["invokername"] . " sent textmessage: " . $event["msg"];
    $id = $event['invokerid'];
    $ts3_VirtualServer->clientGetById('$id')->message("test");
    }

    i think the problem is with the blocking=0 on $ts3_VirtualServer...
    Anybody can help me making this bot reply?

  2. #992
    Join Date
    April 2014
    Location
    Seattle, WA, USA
    Posts
    141

    Variable interpolation in single quote PHP string

    There could be lots of other reasons, but I believe you're using an incorrect format for string interpolation:


    PHP Code:
    $ts3_VirtualServer->clientGetById('$id')->message("test"); 
    String interpolation does not work with single quotes: '
    REF: http://php.net/manual/en/language.types.string.php

    Quote Originally Posted by PHP.net
    Note: Unlike the double-quoted and heredoc syntaxes, variables and escape sequences for special characters will not be expanded when they occur in single quoted strings.
    Thus, the closest solution to your version:

    PHP Code:
    $ts3_VirtualServer->clientGetById("$id")->message("test"); 
    Even better, you do not need quotes:

    PHP Code:
    $ts3_VirtualServer->clientGetById($id)->message("test"); 

    Also, probably not needed, but just in case:

    If you're getting some kind of reference or type error, you can force data types:

    PHP Code:
    $id strval($event['invokerid']);
    $id intval($event['invokerid']);
    // Or type cast with:
    (string) (int)
    $id = (string) $event['invokerid'];
    $id = (int) $event['invokerid'];

    // Or directly in method call:
    $ts3_VirtualServer->clientGetById(intval($id))->message("test"); 
    Otherwise:

    blocking=0 is correct and required for persistent connection.

    Your use of object methods and properties looks fine.

    Do you have any error reporting enabled? This could help quite a bit with debugging. Some examples:

    PHP Code:
    // Enable PHP's built in error reporting:
    /* set error reporting levels */
    error_reporting(E_ALL E_STRICT);

    /* set error reporting levels (int usage is depreciated I believe, constants are now used, meh) */
    ini_set('display_errors'1);

    // I HIGHLY recommend, especially when making any dynamic calls (using data that can change or is pulled from the server, i.e., a client object) to use a Try / Catch statement and utilize the TS3 Framework's exceptions:

    try
    {
        
    $ts3_VirtualServer->clientGetById(intval($id))->message("test");
    }
    catch(
    Exception $e)
    {
        die(
    "[ERROR]  " $e->getMessage() . "\n");
    }

    // For your non-expanded variable, I would expect this to throw: "invalid clientID" since it's trying to look for a client ID == '$id' rather than '1337' or even (int) '1337'
    // foreach(...->clientList() as $clid => $client) ... if ($clid == '$id') return; 
    Last edited by Ronin Design; September 24th, 2014 at 12:13 PM.

  3. #993
    Join Date
    April 2014
    Location
    Seattle, WA, USA
    Posts
    141

    setPredefinedQueryName having no effect

    Not sure if I'm initalizing incorrectly or what, but the built-in method for setting the Server Query nickname is not working for me
    PHP Code:
    // Method: TeamSpeak3_Node_Host::setPredefinedQueryName

    $ts3 TeamSpeak3::factory("serverquery://" $cfg["user"] . ":" $cfg["pass"] . "@" $cfg["host"] . ":" $cfg["query"] . "/?server_port=" $cfg["voice"] . "&blocking=0");
    $ts3->setPredefinedQueryName("[SERVER]"); 
    I get no errors, and using a try/catch no exceptions are thrown... it just is simply ineffective.

    Using the URI parameter: ?nickname=[SERVER] works great, just thought I would post about this in case it's a bug in the framework.

  4. #994
    Join Date
    October 2003
    Location
    Germany
    Posts
    2,527
    Quote Originally Posted by Ronin Design View Post
    Not sure if I'm initalizing incorrectly or what, but the built-in method for setting the Server Query nickname is not working for me

    I get no errors, and using a try/catch no exceptions are thrown... it just is simply ineffective.

    Using the URI parameter: ?nickname=[SERVER] works great, just thought I would post about this in case it's a bug in the framework.
    Well... the setPredefinedQueryName() method just tells the framework to use the specified nickname when you select (use) the next virtual server. Since that already happened in your factory URI, the call has no effect. This should work:

    PHP Code:
    $instance TeamSpeak3::factory("serverquery://" $cfg["user"] . ":" $cfg["pass"] . "@" $cfg["host"] . ":" $cfg["query"] . "/?blocking=0");

    $instance->setPredefinedQueryName("[SERVER]");

    $server $instance->serverGetByPort($cfg["voice"]); 

  5. #995
    Join Date
    February 2014
    Posts
    5

    Create a semi-permanent channel from website.

    Hello guys,

    I've been trying to make an option on my website where people can fill in the desired name and password and the channel will be created but I can't get it working somehow. I've tried it by using the php framework but even after setting the serveradmin query details it still isnt working.

    Can someone post a working script or tell me what I am doing wrong? I am using the example and edited it to my needs but it isnt working, the screen just remains white even tho the title is changed properly so the page is loaded but remains blank.

    Thanks already

    Code:
    <?php
    
    /**
     * Channel Create Example
     * ----------------------
     * Creating channels is very easy using the TeamSpeak 3 PHP Framework. Simply call the appropriate method and provide
     * an associative array containing all the properties you want.
     * 
     * Creating new virtual servers is working the same way.
     */
    
    /* load framework library */
    require_once("libraries/TeamSpeak3/TeamSpeak3.php");
    
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    
    <head>
      <title>Channel Create Example | TeamSpeak 3 PHP Framework <?= TeamSpeak3::LIB_VERSION; ?></title>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    </head>
    
    <body style="font-family: tahoma, arial, verdana, helvetica, sans-serif; font-size: 14px;">
    
    <?php
    
    try
    {
      /* connect to server, login and get TeamSpeak3_Node_Server object by URI */
      $ts3_VirtualServer = TeamSpeak3::factory("serverquery://127.0.0.1:10011/?server_port=9987");
    
      /* create semi-perm channel and get new ID */
      echo "Creating first temporary channel on virtual server " . $ts3_VirtualServer . " ... ";
      $cid1 = $ts3_VirtualServer->channelCreate(array(
        "channel_name" => "My Channel",
        "channel_topic" => "This is my first channel...",
      ));
      echo "Done (ID " . $cid1 . ")<br />\n";
      
      /* create temp sub-channel and get new ID */
      echo "Creating first temporary sub-channel on virtual server " . $ts3_VirtualServer . " ... ";
      $cid2 = $ts3_VirtualServer->channelCreate(array(
        "channel_name" => "My Sub-Channel",
        "channel_topic" => "This is my second channel...",
        "cpid" => $cid1,
      ));
      echo "Done (ID " . $cid2 . ")<br />\n";
      
      /* create temp sub-channel and get new ID */
      echo "Creating second temporary sub-channel on virtual server " . $ts3_VirtualServer . " ... ";
      $cid3 = $ts3_VirtualServer->channelCreate(array(
        "channel_name" => "My Sub-Sub-Channel",
        "channel_topic" => "This is my third channel...",
        "cpid" => $cid2,
      ));
      echo "Done (ID " . $cid3 . ")<br />\n";
    }
    catch(Exception $e)
    {
      echo "Error (ID " . $e->getCode() . ") <b>" . $e->getMessage() . "</b>";
    }
    
    ?>
    
    </body>
    
    </html>

  6. #996
    Join Date
    February 2013
    Posts
    4
    Quote Originally Posted by Death_Balgor View Post
    images not working?

    there is an error in the document.
    Code:
    // 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");
    // build and display HTML treeview using custom image paths (remote icons will be embedded using data URI sheme)
    echo $ts3_VirtualServer->getViewer(new TeamSpeak3_Viewer_Html("images/viewericons/", "images/countryflags/", "data:image"));
    There is a way to keep the connection open to the server query without having to repeat this string?

    Code:
    / 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");
    thks
    I had issues finding the images for this functionality too. I found the old icons which you can get from...

    https://www.dropbox.com/s/ylrtb2mr7b...mages.zip?dl=0

  7. #997
    Join Date
    October 2014
    Posts
    2

    Question about the Ts3 Api

    Hello right now i wan't to make a little Webinterface and use the Ts3 Api but now i have a problem by ServerCreate

    In the API Documentation is standing

    Code:
    $new_sid = $ts3_ServerInstance->serverCreate(array(
    "virtualserver_name" => "My TeamSpeak 3 Server",
    "virtualserver_maxclients" => 64,
    "virtualserver_hostbutton_tooltip" => "My Company",
    "virtualserver_hostbutton_url" => "http://www.example.com",
    "virtualserver_hostbutton_gfx_url" => "http://www.example.com/buttons/button01_24x24.jpg",
    ));
    But what can i use too i now about "virtualserver_port" but what for other are there.

    Sry for my bad English

  8. #998
    Join Date
    February 2014
    Posts
    5
    Can someone please help me and give me a working script to make channels from a php script?

  9. #999
    Join Date
    September 2008
    Location
    England...
    Posts
    40
    Hey ScP, long time.

    Having an issue with my scripts/software connecting to Teamspeak recently. I think it started about a week ago.

    PHP Code:
    // Connection ready
    try {
        
    $ts3_VirtualServer TeamSpeak3::factory("serverquery://".$c->tsname.":".$c->tspass."@".$c->tshost.":".$c->tsport."/?server_port=".$c->tscport);
    } catch (
    TeamSpeak3_Exception $e) {
        echo 
    "Error: ".$e->getMessage()." [A".__LINE__."]";
        break;

    prints:
    Error: connection to server '204.27.59.243:10011' lost [A922]
    Any idea? I have:
    Updated the Framework (1.1.23)
    Checked the web server is in the whitelist
    Web servers outbound port is good
    Teamspeak Server Query port is open and unchanged

  10. #1000
    Join Date
    April 2014
    Location
    Seattle, WA, USA
    Posts
    141
    Hi, I'm personally not very familiar with the error you're getting. However, from what I found in the code it seems like this exception is thrown by some of the lower level interface methods:

    TeamSpeak3_Transport_TCP | TeamSpeak3_Transport_UDP
    REF: https://docs.planetteamspeak.com/ts3...aa8c2da53a3e11

    If the code is consistent, I would imagine this exception is thrown whenever a stream_get_contents, fread, or other stream reading method returns an empty $data value.

    Again, I don't have a deep level of understanding of the framework at this low a level, but maybe:
    a) The client is connecting and then timing out?
    b) The connection is not stable so packets (or entire connection) is dropped, closes or times out the stream, without assigning any length of data to the $data value.
    c) Other interruptions, blocking calls, etc that could mess with TCP / UDP stream access?

    Since you're not getting any errors with authenticating, this is probably not the issue, but have you tested using telnet to port 10011 to see if the raw connection is doing anything weird?

    When I try to connect to the IP in your error message on port 10011, I get the TS server query welcome message, but any command I try to send seems to hang. No further response from the server is sent.

    To me this is exactly what I imagine is happening with the TS3 PHP Framework. It's trying to setup the connection, but then it's timing out after waiting for a response or maybe getting "no response".

  11. #1001
    Join Date
    September 2008
    Location
    England...
    Posts
    40
    Well as nothing is trying to be done except connect it would make sense if it's hanging like you say, so thank you for checking that.
    What confuses me is that we've not found any issues through telnet and this command is failing on just connect. So as you're getting the welcome message, surely it shouldn't be failing until a command is attempted as the server is responding to the connection?

  12. #1002
    Join Date
    June 2012
    Location
    Portugal
    Posts
    317
    Maybe try to debug with tcpdump and executing the php script.

    Then analyse the dump in wireshark and check if anything is wrong.

  13. #1003
    Join Date
    April 2014
    Location
    Seattle, WA, USA
    Posts
    141
    Quote Originally Posted by Mavrik347 View Post
    Well as nothing is trying to be done except connect it would make sense if it's hanging like you say, so thank you for checking that.
    What confuses me is that we've not found any issues through telnet and this command is failing on just connect. So as you're getting the welcome message, surely it shouldn't be failing until a command is attempted as the server is responding to the connection?
    EDIT: The below is what was happening, but now I get a normal behavior through telnet. Maybe it was an intermittent issue? Try again with your script?

    So when connecting to your server via telnet on port 10011, I ONLY get the welcome message, no matter what, even if I send additional commands, I never get another response after the initial / first "welcome" message. This is what makes me think the connection is timing out (and my additional commands never reach the server?).

    Just to clarify further, here's what happens when I telnet in:

    Client> Telnet <IP> <Port>
    Servr> Welcome to...
    Client> serverlist
    Client> help serverlist
    Client> help serverinfo


    I never get another response after the first message, at all. Even when I restart the connection and test send each command individually, I always ONLY get the first welcome message and then no further data is transmitted.

    It seems like the server sends the initial message, then that socket closes, or something is interfering with the TS3Server listening or actually seeing any further commands.
    Last edited by Ronin Design; October 13th, 2014 at 03:47 AM.

  14. #1004
    Join Date
    September 2012
    Posts
    6,079
    Quote Originally Posted by supergoudvis View Post
    Hello guys,

    I've been trying to make an option on my website where people can fill in the desired name and password and the channel will be created but I can't get it working somehow. I've tried it by using the php framework but even after setting the serveradmin query details it still isnt working.

    Can someone post a working script or tell me what I am doing wrong? I am using the example and edited it to my needs but it isnt working, the screen just remains white even tho the title is changed properly so the page is loaded but remains blank.

    Thanks already
    You have a syntax error in line 21
    When sending PMs please make sure to include a reference link to the thread in question in the body of your message.

  15. #1005
    Join Date
    October 2014
    Posts
    3
    Is there any way how to get channel admins?

Thread Information

Users Browsing this Thread

There are currently 9 users browsing this thread. (0 members and 9 guests)

Similar Threads

  1. PHP Framework
    By Multivit4min in forum Permission System
    Replies: 1
    Last Post: June 29th, 2015, 12:28 PM
  2. PHP Framework
    By phil998 in forum Server Support
    Replies: 0
    Last Post: February 25th, 2015, 07:27 PM
  3. TS3 PHP Framework Visualizations
    By Ronin Design in forum Tools / Web Based
    Replies: 2
    Last Post: February 22nd, 2015, 06:04 AM
  4. Extraction using the Framework
    By HarryMW in forum Tools / Web Based
    Replies: 1
    Last Post: August 3rd, 2012, 08:04 PM
  5. Teamspeak, PHP Framework?
    By mario2027 in forum General Questions
    Replies: 1
    Last Post: December 21st, 2010, 10:30 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •