Display servers via PHP on website
Display servers via PHP on website
I tried to Display Servers via the TwRequest.php but it don't work.
As output my webserver say:
what do I have to do?
The CodeShow
Code: Select all
<?php
// include the class
require_once("./TwRequest.php");
// create object
$request = new TwRequest;
// add servers
$request->addServer("188.165.209.72", 7149, TwRequest::VERSION_06);
// request the statuses
$request->loadServerInfo();
// go through each server and print out the information
foreach ($request->getServers() as $server) {
echo "Server: ".$server[0].":".$server[1]."<br>\n";
// check if the request was successful
if (isset($server['version'])) {
// it was
echo "Version: ".$server['version']."<br>\n";
echo "Name: ".$server['name']."<br>\n";
echo "Map: ".$server['map']."<br>\n";
echo "Gametype: ".$server['gametype']."<br>\n";
if ($server['password']) {
echo "Password protected: yes<br>\n";
} else {
echo "Password protected: no<br>\n";
}
// progression is 0.5 only
if ($server[2] == TwRequest::VERSION_05) {
echo "Progression: ".$server['progression']." %<br>\n";
}
echo "Players: ".$server['num_players']." / ".$server['max_players']."<br>\n";
// ingame players is 0.6 only
if ($server[2] == TwRequest::VERSION_06) {
echo "Players ingame: ".$server['num_players_ingame'].
" / ".$server['max_players_ingame']."<br>\n";
}
echo "Player list:<br>\n";
// check if players are online
if (count($server['players']) == 0) {
echo "no players online<br>\n";
}
else {
echo "<ul>\n";
foreach ($server['players'] as $player) {
echo "<li>\n";
echo "Name: ".$player['name']."<br>\n";
echo "Score: ".$player['score']."<br>\n";
// this is 0.6 only
if ($server[2] == TwRequest::VERSION_06) {
echo "Clan: ".$player['clan']."<br>\n";
echo "Country: ".TwRequest::getCountryCode($player['country']).
" (".TwRequest::getCountryName($player['country']).")<br>\n";
if ($player['ingame']) {
echo "This player is ingame.<br>\n";
} else {
echo "This player is in spectator mode.<br>\n";
}
}
echo "</li>\n";
}
echo "</ul>\n";
}
}
else {
// it was not
echo "Request failed<br>\n";
}
echo "<br>\n";
}
?>
what do I have to do?
Re: Display servers via PHP on website
problem solved php-friends.de doesn't support fsocketopen or something like that >.>
however this thread can get closed
however this thread can get closed
Re: Display servers via PHP on website
I have a status api running for Teeworlds Server. It can be requested via http and you will receive detailed information in JSON format:
example:
http://ebeur.eastbit.net:8888/server/95.172.92.151/8322
If php-friends.de also doesn't support AJAX you can still request this information via javascript.
example:
http://ebeur.eastbit.net:8888/server/95.172.92.151/8322
If php-friends.de also doesn't support AJAX you can still request this information via javascript.
Re: Display servers via PHP on website
is it possible to ask the masterservers and search for particular names?
I want to display on our website beside our clan servers the "Members ingame:"
I want to display on our website beside our clan servers the "Members ingame:"
Re: Display servers via PHP on website
Well, it's possible. I'll need to add some code though. Do you have a simple clan tag usable for the search or does it require specific names?
Who is online
Users browsing this forum: No registered users and 2 guests