Writing a Facebook App 1

A while ago, I wrote a Facebook App called “Simple Friends” that would display a list of your friends, where you could click their name to view their profile. It was simple enough, but I recently wanted to create a somewhat more sophisticated app.

I won’t bother going through the whole process, because there are great tutorials out there. I just wanted to share one piece of the puzzle that had me stuck for quite some time.

There is a function called setFBML which allows you to set the content’s of different sections of the user’s profile (i.e. get things to show up on their profile page. This was great, because I wanted to make a drop down list of friends to go on the user’s profile. Selecting a friend from the drop down would take you directly to their page.

I kept getting a message on my profile saying that there was no content available, and the content wouldn’t be available until my application created the content. I couldn’t figure this message out for the life of me. After lots of Google searches, I finally found someone who had the solution.

In PHP, the function profile_setFBML() was actually missing a parameter. I tried to update the function with the new parameter, but I couldn’t get that to work. I was finally able to call the function directly, and it looked something like this….

$facebook->api_client->call_method('facebook.profile.setFBML', array(
'uid' => $user_id,
'profile' => $markup,
'profile_main' => $markup));

$user_id is the id of the user who has the application installed. profile specifies what will show up if the user adds the application to their “Boxes” tab. The real kicker was profile_main, which specifies what should be displayed if the user adds your application to their actual profile page.

Check out my app, Lazy Friends, at http://apps.facebook.com/lazyfriends/

One comment on “Writing a Facebook App

  1. Reply danielle Dec 29,2008 1:36 pm

    you are such a nerd – i love how excited you get about stuff like this 🙂 🙂

Leave a Reply