Got Ads?
7/06/2007
  Finding Sample Code for Facebook Apps

So you want to build a facebook app? The easiest thing to do is find someone else's code and modify it for your purposes. Especially since the facebook API documentation isn't really that good yet.

Unfortunately, Facebook Apps aren't automatically open, like say HTML or Javascript pages are. So you can't just look at the code of a working application. That's too bad. It would help a lot.

As it stands, the Facebook docs have a dearth of sample code for the Facebook API.

However, in the process of writing my first Facebook App, I spent a lot of time Googling (try looking for 'facebook.php' and other common include files on google.com/codesearch), reading forums, the facebook developer wiki and blogs.

So here's an omnibus post on where to find example code for Facebook apps, and also a bunch of good links to posts that explain how to write a Facebook app.

Sources For Sample Code For Facebook Apps

Other Tips for Building Facebook Applications

A few bloggers have created posts which do a good job explaining how facebook apps work from a programming point of view. These are useful to read as you get started.

Facebook App Architecture Notes

The Washington Post has a team integrating on F8. Best of all, they have some bloggers writing about Facebooks apps in depth.

Here's a sample of their blogging about the architecture:

Facebook user's data in a generic fashion. The real advantage of this approach is that with just the UID of a Facebook user, I can load related data in a Facebook page or on the user's profile without having to do any processing on my end. For example, this --
        {% for friend in friends %}
               <fb:profile-pic uid="{{ friend }}" />
                   <fb:userlink uid="{{ friend }}">
                      <fb:name uid="{{ friend }}" useyou="false" />
                </fb:userlink>
        {% endfor %}
is an example in Django template syntax using FBML that would produce a list of friends with pictures.

Here are more tips and tricks to understanding the facebook platform from the devurandom guys. Some example code in Python in this post.

Excerpt:

Notice there is a "Callback URL" and a "Canvas Page URL". The callback URL is the base URL on the developer's server (washingtonpost.com in our case); the canvas page URL is the base URL on Facebook's server. When you install our app on Facebook, you are redirected to the canvas page URL, which in turn fetches content from the callback. You can have any number of callback pages extending off the base. If you went to apps.facebook.com/thecompass/foo/, then that page would fetch content from specials.washingtonpost.com/politicompass/foo/.

Now you can't go directly to specials.washingtonpost.com/politicompass/ because without the POST data Facebook submits to the callback URL, the application won't work. If you hit our server directly without coming through Facebook, we redirect to the Facebook URL for our app. In fact, every time Facebook hits our callback URL there is a little setup that has to be done for each request

Commentary from 20bits on Building Facebook Apps

Sample FBML code and description of application architecture.

How to make a good social app so it fits in Facebook

Gotchas when using the platform. Part I. Part II.

Tips from MyMoods developer on Getting Started with a Facebook App

10 Things that would have been nice to know when starting my facebook application

Sample Hint on updating users' profiles:

To do a more periodic update, you can just iterate over all your users, get their uids, and call profile_setFBML() on each. Remember, from above, you don't need to call set_user for each, just use your own session_key.

10 Tips on Getting your Facebook App approved and Growing Users

From inside facebook - 10 tips on promoting your app
  1. Spend time on your icons and screenshots - This is the first interaction your potential users will have with your app, so it had better be impressive, especially if you have competitor apps already out in the wild. There are three pieces to worry about: an application icon (16 x 16 pixels), an application logo (75 x 75 pixels) and a screenshot of any size you choose (which will be resized to the width of your About page). Make sure you have all of these ready to go before taking your app live.

Let me know if you find other examples and sample code, and I'll add it to this post.

Labels: ,

 




<< Home

Subscribe to GotAds?



Links



Recent Posts

Finding Sample Code for Facebook Apps


Archives

February 2005 /  March 2005 /  April 2005 /  May 2005 /  June 2005 /  July 2005 /  August 2005 /  September 2005 /  October 2005 /  November 2005 /  December 2005 /  January 2006 /  February 2006 /  March 2006 /  April 2006 /  May 2006 /  June 2006 /  July 2006 /  August 2006 /  September 2006 /  October 2006 /  November 2006 /  December 2006 /  January 2007 /  February 2007 /  March 2007 /  April 2007 /  May 2007 /  June 2007 /  July 2007 /  August 2007 /  September 2007 /  October 2007 /  November 2007 /  December 2007 /  January 2008 /  February 2008 /  March 2008 /  April 2008 /  May 2008 /  June 2008 /  July 2008 /  August 2008 /  September 2008 /  November 2008 /  December 2008 /  January 2009 /  March 2009 /