In Learning FBML - Part 1, we have learnt how to use some of the page navigation related features in FBML.

In part 2, we will take a look at some of the user related features in FBML.

You can refer to the official FBML documentation for the user related features here.


FBML Used in Our 1st Facebook App

In our 1st Facebook App, we have already used the <fb:name> tag:

// Greet the currently logged-in user!
echo "<p>Hello, <fb:name uid=\"$user_id\" useyou=\"false\" />!</p>";

The <fb:name> tag is mainly used to render the name of the user specified in the uid parameter (including the current user and other users). By specifying optional parameter such as "useyou", "possessive", "lastnameonly" etc, we can also display various form of the user name such as displaying the reflexive and possessive of the user or displaying just the last name. Please refer to the official documentation for the details.

Referring to our 1st Facebook app, currently, only the IDs of the current user's friends are displayed. if we want to display the name, we can revise the code as shown below:

foreach ($friends as $friend) {
// echo "<br>$friend";
echo "<br><fb:name uid=\"$friend\" />";


Displaying User's or Facebook Page's profile Profile Pic - fb:profile-pic

The <fb:profile-pic> tag is easy to use. Its usage is similar to the <fb:name> tag.

To display the profile picture of the user's friends next to the name, simply revise our 1st Facebook App code as shown below:

foreach ($friends as $friend) {
// echo "<br>$friend";
echo "<br><fb:profile-pic uid=\"$friend\" width=\"50\" height=\"50\" /><fb:name uid=\"$friend\" />";


We will talk about more FBML features later. Meanwhile, let's try testing other user related FBML features.