May 16, 2010
Add Profile Box Using Facebook Application
Most of my friends who are eager on developing facebook application ask me about how to create add profile box to their profile. Here, i’m gonna show you how to make it. Lets assume that you already understand the basic steps to create facebook application using php platform.
Profile.setFBML - That’s what we’re gonna use to add the profile box, you can read more about it on Facebook Developer Wiki
Sets the FBML for a user’s profile or Facebook Page, including:
- The content for the profile box on the Wall tab
- The profile box for the Boxes tab, both narrow and wide
- The FBML for a mobile device
There are several steps to add content to a User’s profile with profile.setFBML:
- interact with the user to gather compelling content
- call profile.setFBML
- induce the user to click on an Add to Profile button
- (optional) induce the user click on an Offline Access button or otherwise grant this permission
Interacting with the user to gather compelling content is highly dependent on your application. You may achieve this in one session, or it might require several interactions with the user.
Example Source Code
<?php
require_once 'PATH_TO_YOUR_LIB/facebook.php';
$appapikey = 'YOUR_API_KEY';
$appsecret = 'YOUR_API_SECRET';
$facebook = new Facebook($appapikey, $appsecret);
$user = $facebook->require_login();
$profile = "<fb:narrow>Narrow Content for Boxes tab</fb:narrow><fb:wide>Wide content for Boxes tab</fb:wide>";
$mobile_profile = "Content for Mobile devices";
$profile_main = "Content for main profile page, under user's photo";
$facebook->api_client->profile_setFBML(NULL, $user, $profile, NULL, $mobile_profile, $profile_main);
?>
<fb:add-section-button section="profile" />
require_once 'PATH_TO_YOUR_LIB/facebook.php';
$appapikey = 'YOUR_API_KEY';
$appsecret = 'YOUR_API_SECRET';
$facebook = new Facebook($appapikey, $appsecret);
$user = $facebook->require_login();
$profile = "<fb:narrow>Narrow Content for Boxes tab</fb:narrow><fb:wide>Wide content for Boxes tab</fb:wide>";
$mobile_profile = "Content for Mobile devices";
$profile_main = "Content for main profile page, under user's photo";
$facebook->api_client->profile_setFBML(NULL, $user, $profile, NULL, $mobile_profile, $profile_main);
?>
<fb:add-section-button section="profile" />
Note:
You must pass NULL between 'profile' and 'mobile_profile' to account for the deprecated 'profile_action' parameter.
Facebook will deprecate this tag in late 2009/early 2010. In the other word, we can only add it to boxes tab later when it happen.
Happy developing facebook application







Media-Box
May 18th, 2010 at 3:42 PM
ijin pake ya om…
nice tutor ckckckkckckck
buat js linker dong buat fb ya wakakakakka
May 19th, 2010 at 9:29 AM
mantap wa
May 20th, 2010 at 11:00 AM
klo yang bukan tabbox gmn?
May 21st, 2010 at 3:56 PM
Terrific work! This is the type of information that should be shared around the web. Shame on the search engines for not positioning this post higher!
June 17th, 2010 at 5:32 AM
weee.. thanks for posting this joy.. i was really confused on how i’m going to setup that widget code
July 18th, 2010 at 4:46 AM
Good job!
August 4th, 2010 at 3:03 PM
dude,
i think
$facebook->api_client->profile_setFBML(NULL, $user, $profile, NULL, $mobile_profile, $profile_main);
and
tags are deprecated can you tell me how to make this work in new facebook.
August 8th, 2010 at 8:12 PM
unfortunately yes, they have already removed the tags. no more add to profile box except to their wall tab. if you still have any applications added to your profile, like profile blanker, animated aboutme or else kindly dont remove it, coz you wont be able to add it again after
i’ll try to play again with facebook application later when all my recent projects done
August 27th, 2010 at 4:59 AM
ManTabzZZ GAN….
August 31st, 2010 at 5:19 AM
sayang modulnya udah gadipake lagi sm facebook, skrg kita cm bs add to wall tab