Ok, after I fixed the line:
PHP Code:
else if ($line) == '')
It worked for the rooms. But the users shows a comma after the name now (like in the attched pic).
Here is the code I am using that you sent me after the line fix:
PHP Code:
$port = 10010;
function getServerAPI($apiCommand)
{
global $port;
$result = "";
$fp = fsockopen("localhost", $port, &$errno, &$errstr, 2);
if (!$fp)
{
echo "$errstr ($errno)\n";
}
else
{
fputs($fp,"GET /?".$apiCommand." HTTP/1.0\n\n");
$header = true;
while(!feof($fp))
{
$line = fgets($fp,128);
if ($header == false AND ($line = trim($line)) != '')
{
$result .= "$line, ";
}
else if (trim($line) == '')
{
$header = false;
}
}
fclose($fp);
}
return substr($result, 0, -2); // trim the last ', '
}
$userCount = getServerAPI( "api.UserList" );
$roomList = getServerAPI( "api.RoomList" );