What is a handler.
A handler is a server script, that returns data (usually in XML format) to the application upon request. For example, it can return user profile information or user authorization information.
All handlers can be edited in the application main settings file /flashcoms/Community Messenger/settings/main.xml,
however, make sure you’re not removing markers, like: {ROOT}, {NAME} and {UID}. These are system markers in which the application inserts the appropriate values.
Depending on the application and handler you may find several different markers. The most commonly used markers are:
| ROOT |
root folder for all flashcoms applications (PROJECT_HTTP_ROOT/flashcoms/). |
| NAME |
user name. |
| UID |
user identifier (used when site authorization is not session/cookies based) |

{ROOT} marker value ends with “/”, so if you change the path of the handler file to, for example, /avatar.php located in the PROJECT_HTTP_ROOT folder, then the new address path should look like this: {ROOT}../avatar.php |
Handlers can be edited in the handlers sections of the main settings file (/flashcoms/Community Messenger/settings/main.xml)
<handlers>
<auth> <![CDATA[ {ROOT}Community Messenger/server/php/handlers.php?action=auth&uid={UID}
]]</auth>
<profile><![CDATA[ {ROOT}Community Messenger/server/php/handlers.php?action=getProfile&userName={NAME}
]]></profile>
<userInfo><![CDATA[ {ROOT}Community Messenger/server/php/handlers.php?action=photo&userName={NAME}
]]></userInfo>
<uploadDownloadFile>< ![CDATA[ {ROOT}common/server/php/file.php
]] ></uploadDownloadFile>
</handlers> |
Authorization handler
<auth> <![CDATA[ {ROOT}Community Messenger/server/php/handlers.php?action=auth&uid={UID}
]]</auth>
|
Authorization handler allows you to integrate the Community Messenger with your web site users' database.
Parameters:
UID - optional parameter which receives user identifier that has been passed to
the application. Used for non session/cookies based authorization.
If authorization is passed successfully:
<auth error="">
<userName><![CDATA[USERNAME]]></userName>
<gender>male</gender>
<level>regular</level>
</auth>
|
where:
| Node name |
Description |
| userName |
Required. User login name. |
| gender |
User's gender. Can take 'male', 'female' or 'couple' value. Required when avatar mode is set to "gender" |
| level |
User's authorization level. Required when limitation plugin is installed. |
If not authorized:
<auth error="AUTH_ERROR" /> |
Example code below illustrates the handler logic:
//check if is set session variable
if(!isset($_SESSION["user_id"])) echo '< site_auth error="AUTH_ERROR" >;
else { //connect to users database
$db = mysql_connect(DB_HOST,DB_USER,DB_PASSWORD)
or die(mysql_error()); mysql_select_db(DB_NAME,$db) or die(mysql_error()); //select
information for current user from database $sql = "SELECT * FROM users_table WHERE
user_id=".$_SESSION["user_id"]; $result = mysql_query($sql,$db); $users_row = mysql_fetch_array($result);
//return information about user in xml format to the Community Messenger
echo '< auth
error="" >';
echo '< name >'.$users_row['user_name'].'< /name >';
echo
'< level >'.$users_row['user_gender'].'< /level >';
echo '< /auth >';
}
//where $_SESSION["user_id"] is a session variable which is initialized when a user
logged in to your site
|
Profile handler
Returns user’s profile information.
Parameters:
userName – user name.
Format of the returned data
<profile>
<paramName>value</paramName >
<paramName>value</paramName>
…
<paramName>value</paramName>
<paramName>value</paramName>
</profile> |
Example:
<profile>
<name>SomeName</name>
<age>22</age>
<gender>male</gender>
<info>my info </info>
<photo width="80" height="80">http://www.yourdomain.com/avatars/user_avatr.jpg</photo>
</profile>
|
|
//select information for current user from database
$sql = "SELECT * FROM users_profile_table WHERE user_name LIKE ‘".$_GET["userName"].”’”;
$result = mysql_query($sql,$db);
$users_row = mysql_fetch_array($result);
//return information about user in xml format to the Community Messenger
echo '<profile>';
echo '<name>'.$users_row['user_name'].'</name>';
echo '<gender>'.$users_row['user_gender'].'</gender>';
echo '<age>'.$users_row['user_age'].'</age>';
echo '<info>'.$users_row['user_info'].'</info>';
echo '<country>'.$users_row['user_ country'].'</country>';
echo '<photo width="80" height="80">'. 'http://www.yourdomain.com/photo_folder/'.$users_row['user_photo']. '</photo>';
echo '</profile>';
//where |
$_GET["userName"] is a user name variable which we get from Flashcoms Community Messenger
Info handler
Parameters:
userName – user name
Returnes xml data.
Format of the returned data
<info>
<name>value</name >
<gender>value</gender>
<level>value</level>
<photo>value</photo>
<photoModeImage>value</photoModeImage>
</info> |
Example:
<info>
<name>Some Name </name >
<gender>male</gender>
<level>regular</level>
<photo>http://www.yourdomain.com/avatars/user_photo.jpg</photo>
<photoModeImage>http://www.yourdomain.com/avatars/user_avatr.jpg</photoModeImage>
</info> |
|

Profile photo image size is 80x80 pixels, however if you pass an image of a larger
or smaller size it will be resized automatically. Nevertheless, we do not recommend
to pass images larger than 300x300 pixels.
|
|