The Scripting API commands allow you to retrieve information from your RealChat Server. For example, you can show
your visitors who is online from a cutsom ASP or PHP page, before they enter the chat room.
API commands are served by the built-in Control Center HTTP server and are accessible from trusted IPs only. You can
access the commands with a web browser; for example, http://chathost:controlport/?api.Time will return
the current server time.
WARNING: This feature may slow down your chat server, as a connection to the server is made each
time a visitor to your site opens a page containing API calls. You should use the scripting apis with care. If your
website is heavily loaded, you may need to implement a caching mechanism.
To use scripting, you must include the results of an external URL within your standard HTML response. This PHP example displays the number of currently connected users and a list of available rooms:
<?php
function getAPI($command) {
$er = error_reporting(0);
$result = file_get_contents("http://chathost:controlport/?api.".$command);
error_reporting($er);
return $result;
}
echo "Number of users: ".getAPI("UserCount")."<br/>";
echo "Rooms available: ".getAPI("RoomList");
?>
Time- returns the current server time.
InMPS, OutMPS- current incoming/outgoing messages per second.
UserCount- number of users connected.
RoomCount- number of available rooms.
RoomList- a comma delimited list of available rooms.
DetailedRoomList- a list of rooms with each room formatted as: roomID: roomName (userCount)
UsersIn=room- a comma delimited list of all the users in the specified room.
WhereIs=user- finds the room where the specified user is; returns nothing if the user is not found.
WhoWhere- lists all of the users in all rooms; with one room per line, formatted as: roomID: roomName: userList.
Broadcast=message- broadcasts the specified message to all users in all rooms.
SendToRoom=room,message- broadcasts the specified message to all users in the specified room.
SendToUser=user,message- sends a private message to the specified user.
AddRoom=name,topic,password,hidden- creates a room with the specified parameters. If password is left blank, the room is made public; if hidden is skipped, the room is made visible.
RemoveRoom=room- deletes the specified room.
SaveConfiguration- by default rooms created/deleted via the API are non-permanent and last until the next server restart. If you like the changes to be permanent use this command.
Arguments with spaces need to be passed URL-encoded, for example The%20Lobby instead of
The Lobby.
If an error occurs, the server response is always prefixed with ERR:.
With RealChat ISP Edition, all API commands return information for the first, or default, virtual server.
If you want to check a specific virtual server, add vs=serverID, for example,
api.vs=3,UserCount will return the number of users connected to the virtual server with an ID of
3.