Introduction
What is the TS3 PHP Framework?
Initially released in January 2010, the TS3 PHP Framework is a powerful, open source, object-oriented framework implemented in PHP 5 and licensed under the GNU General Public License. It's based on simplicity and a rigorously tested agile codebase. Extend the functionality of your servers with scripts or create powerful web applications to manage all features of your TeamSpeak 3 Server instances.
Tested. Thoroughly. Enterprise-ready and built with agile methods, the TS3 PHP Framework has been unit-tested from the start to ensure that all code remains stable and easy for you to extend, re-test with your extensions, and further maintain.
Why should I use the TS3 PHP Framework rather than other PHP libraries?
The TS3 PHP Framework is a is a modern use-at-will framework that provides individual components to communicate with the TeamSpeak 3 Server.
There are lots of arguments for the TS3 PHP Framework in comparison with other PHP based libraries. It is the most dynamic and feature-rich piece of software in its class. In addition, it's always up-to-date and 100% compatible to almost any TeamSpeak 3 Server version available.
Requirements
The TS3 PHP Framework currently supports PHP 5.2.1 or later, but we strongly recommend the most current release of PHP for critical security and performance enhancements. If you want to create a web application using the TS3 PHP Framework, you need a PHP 5 interpreter with a web server configured to handle PHP scripts correctly.
Note that the majority of TS3 PHP Framework development and deployment is done on nginx, so there is more community experience and testing performed on nginx than on other web servers.
Features
Features of the TS3 PHP Framework include:
- Fully object-oriented PHP 5 and E_STRICT compliant components
- Access to all TeamSpeak 3 Server features via ServerQuery
- Integrated full featured and customizable TSViewer interfaces
- Full support for file transfers to up- and /or download custom icons and other stuff
- Powerful error handling capablities using exceptions and customizable error messages
- Dynamic signal slots for event based scripting
- ...
Usage Examples
1. Kick a single Client from a Virtual Server
require_once("libraries/TeamSpeak3/TeamSpeak3.php");
2. Kick all Clients from a Virtual Server
require_once("libraries/TeamSpeak3/TeamSpeak3.php");
$arr_ClientList = $ts3_VirtualServer->clientList();
3. Print the Nicknames of connected Android Clients
require_once("libraries/TeamSpeak3/TeamSpeak3.php");
$arr_ClientList = $ts3_VirtualServer->clientList(array("client_platform" => "Android"));
foreach($arr_ClientList as $ts3_Client)
{
echo $ts3_Client . " is using " . $ts3_Client["client_platform"] . "<br />\n";
}
4. Modify the Settings of each Virtual Server
require_once("libraries/TeamSpeak3/TeamSpeak3.php");
foreach($ts3_ServerInstance as $ts3_VirtualServer)
{
$ts3_VirtualServer["virtualserver_hostbanner_gfx_url"] = "http://www.example.com/banners/banner01_468x60.jpg";
$ts3_VirtualServer->virtualserver_hostbanner_gfx_url = "http://www.example.com/banners/banner01_468x60.jpg";
$ts3_VirtualServer->modify(array(
"virtualserver_hostbutton_tooltip" => "My Company",
"virtualserver_hostbutton_url" => "http://www.example.com",
"virtualserver_hostbutton_gfx_url" => "http://www.example.com/buttons/button01_24x24.jpg",
));
}
5. Create a Privilege Key for a Server Group
require_once("libraries/TeamSpeak3/TeamSpeak3.php");
$arr_ServerGroup = $ts3_VirtualServer->serverGroupGetByName("Admins");
$ts3_PrivilegeKey = $arr_ServerGroup->privilegeKeyCreate();
6. Modify the Permissions of Admins on each Virtual Server
require_once("libraries/TeamSpeak3/TeamSpeak3.php");
foreach($ts3_ServerInstance as $ts3_VirtualServer)
{
$ts3_ServerGroup = $ts3_VirtualServer->serverGroupIdentify();
$ts3_ServerGroup->permAssign("b_virtualserver_modify_hostbanner", TRUE);
$ts3_ServerGroup->permRemove("b_virtualserver_modify_maxclients");
}
7. Create a new Virtual Server
require_once("libraries/TeamSpeak3/TeamSpeak3.php");
$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",
));
8. Create a hierarchical Channel Stucture
require_once("libraries/TeamSpeak3/TeamSpeak3.php");
$top_cid = $ts3_VirtualServer->channelCreate(array(
"channel_name" => "My Channel",
"channel_topic" => "This is a top-level channel",
"channel_flag_permanent" => TRUE,
));
$sub_cid = $ts3_VirtualServer->channelCreate(array(
"channel_name" => "My Sub-Channel",
"channel_topic" => "This is a sub-level channel",
"channel_flag_permanent" => TRUE,
"cpid" => $top_cid,
));
9. Create a simple TSViewer for your Website
require_once("libraries/TeamSpeak3/TeamSpeak3.php");
echo $ts3_VirtualServer->getViewer(
new TeamSpeak3_Viewer_Html(
"images/viewericons/",
"images/countryflags/",
"data:image"));
10. Update all outdated Audio Codecs to their Opus equivalent
require_once("libraries/TeamSpeak3/TeamSpeak3.php");
foreach($ts3_VirtualServer->channelList() as $ts3_Channel)
{
{
}
{
}
}
11. Display the Avatar of a connected User
require_once("libraries/TeamSpeak3/TeamSpeak3.php");
$ts3_Client = $ts3_VirtualServer->clientGetByName("John Doe");
$avatar = $ts3_Client->avatarDownload();
echo $avatar;
12. Create a Simple Bot waiting for Events
require_once("libraries/TeamSpeak3/TeamSpeak3.php");
$ts3_VirtualServer->notifyRegister("textprivate");
while(1) $ts3_VirtualServer->getAdapter()->wait();
{
echo "Client " . $event["invokername"] . " sent textmessage: " . $event["msg"];
}
13. Handle Errors using Exceptions and Custom Error Messages
require_once("libraries/TeamSpeak3/TeamSpeak3.php");
try
{
$ts3_Channel = $ts3_VirtualServer->channelGetByName("I do not exist");
}
{
echo "Error " . $e->getCode() . ": " . $e->getMessage();
}
14. Save Connection State in Persistent Session Variable
require_once("libraries/TeamSpeak3/TeamSpeak3.php");
session_start();
$_SESSION["_TS3"] = serialize($ts3_VirtualServer);
15. Restore Connection State from Persistent Session Variable
require_once("libraries/TeamSpeak3/TeamSpeak3.php");
session_start();
$ts3_VirtualServer = unserialize($_SESSION["_TS3"]);
$ts3_VirtualServer->message("Hello World!");
Speed up new development and reduce maintenance costs by using the TS3 PHP Framework!