Friend List integration
The whole scenario is that the chat server will integrate the friendlist from an external database through dynamic application, like PHP, ASP, ASP.net or JSP if Friendlist module is enabled in chat server. The script will be used to add, remove, and query database.
Parameters List:
The following parameters and values should not be changed.
Parameter | Value | Description |
action | %action% | This defines the action that the script will perform: 0:Query Friend 1:Add Friend 2:Remove Friend 3:Update Friend |
username | %username% | This defines the user who will perform the action |
destusername | %destusername% | This defines the user whose information entry the script will process |
friendgroup | %friendgroup% | This defines the action that the server will perform. |
The Application Return:
The application will return an xml-formatted string to chat server for further processing
Action | Necessary Parameter | Parameter example | Return |
0:Query Friend | Action, username | Action=0&username=jack It indicates all of jack's friend will be returned | <UD> <FL> <g n="general"> <u n="tom"> </g> <g n="stranger"> <u n="rose">" </g> </FL> </UD This returning value indicates tom is jack's friend, rose is not jack's friend, but jack is rose's friend |
1:Add Friend | Action, username, destusername, friendgroup | 1.Action=1&username=jack&destusername=tom& friendgroup=general It means jack add tom as his friend 2.Action=1&username=jack&destusername=tom& friendgroup=stranger It indicates jack won't add tom as his friend | <FL r=" 0"> It indicates the friend is added successfully (if tom is already jack's friend before, it also returns success) <FL r=" 1"> It indicates it failed to add the friend |
2:Remove Friend | Action, username, destusername | Action=2&username=jack&destusername=tom It indicates jack will remove tom from his friend list | <FL r=" 0"> It indicates the friend is removed successfully (if tom is already not jack's friend before, it also returns success) <FL r=" 1"> It indicates it failed to remove the friend |
3:Update Friend | Action, username, destusername, friendgroup | Action=3&username=jack&destusername=tom& friendgroup=general. It indicates jack will "Add Friends" Action=3&username=jack&destusername=tom& friendgroup=stranger. It indicates jack will "Remove Friends" | |
Sample configuration:
In <123flashchat installed directory>/server/etc/groups/default/server.xml <integrated-user-data url="http://yoursite/userdata.php?action=%action%&username=%username%&
destusername=%destusername%&friendgroup=%friendgroup%" charset="UTF-8" enable="On">
</integrated-user-data>
Sample Code:
You can download sample code from here:
The sample Friendlist database can be generated from friendlist.sql.
The sample code could be used directly if you have imported the sample database and configure the user-data-url in server.xml
after restarting your chat server.
You could modify the value of following parameter integrate chat server with Friendlist table in your user databas.
$addFriendSql: The SQL sentence will add a friend.
$removeFriendSql: The SQL sentence will remove a friend.
$queryFriendSql: This SQL sentence will get the usernames on your friendlist.
$opQueryFriendSql: The SQL sentence will get list that whose friend included "username" if the one who is not on "username" friend list.
$checkRowSql: The SQL sentence will check the existence of the username and destusername record in friend table.
$userNameRowField:The user name field in your user table.
$user->setDb($db): $db will be your database link.