Java JSP code example: A Facebook “invite your friends” panel

Posted by lee on February 22nd, 2008

When developing a Facebook application, there are plenty of platform integration points to consider. One of the most essential is the invite panel. This is where users will share your application with their friends. If there’s a bug in your invite panel, your application will never be able to “go viral” and take over world.

Technically, the official documentation does accurately describe the requirements for creating an invite panel. However, I found several gotchas when creating one, so provide the following example in JSP for interested readers. (Notes and screenshots below).

1
2
3
4
5
6
7
8
9
10
11
12
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
 
<c:set var="invite">
  You can use Friends Connection to introduce me to your other friends.
  I can't wait to meet and chat with them!
  &lt;fb:req-choice url='http://apps.facebook.com/friendsconnection/index.htm' label='Make new friends' /&gt;
</c:set>
 
<fb:request-form type="friends connection" content="${invite}" invite="true"
                 action="http://apps.facebook.com/YOURAPPHERE/index.htm">
  <fb:multi-friend-selector rows="4" actiontext="Connect yourself with your friends' friends" />
</fb:request-form>

The JSP above will create the following invite panel, (friend names blacked-out for privacy):

Facebook Invite Panel

Most of this panel is as it will appear for your own application, (albeit with different friend pictures!) The following items are easy to customize:

  1. The main heading
  2. The text on the invite button
  3. The text that will be sent to prospective application users, (ie. the invitation panel shown below).
  4. The request form “type” - this is a small phrase that identifies your application

If you want to preview how the invite will look on the ‘requests’ page of prospective users, select any friend and click the button; the panel will appear as below:Facbeook Invite Panel with an “invite” button

Customizing the “You have an XXXXX invitation.” panel is filled with gotchas. At first glance it appears simple - you add some text using the content attribute of fb:request-form. However, it’s easy to miss the fact you must add the invite buttons to that attribute as well, in FBML format! And they must be entity-escaped to be valid XML!

To make this in a maintainable way, you can set a page request variable using c:set, and simply escape the < and > symbols into &lt; and &gt; yourself. Using single quotes for the fb:req-choice attributes avoids the need to escape double quotes.

The easiest thing to do is copy and paste the code example above, try it out, tweak it and try it some more. If you’re still at a loose end, try the official documentation pages for fb:request-form, and fb:req-choice (though don’t get side-tracked by fb:request-submit-button as it is not relevant).

If you’re still having trouble, or have any suggestions of your own to make this process a little simpler, please drop your comments in the box below.

Jack and the (subversion controlled) Beanstalk

Posted by lee on February 16th, 2008

As a developer, have you ever wanted to banish your fears of hard disk failure and stupid mistakes in one easy step? Did you ever consider that using a hosted version control system could do just that? It’s long been established that using a version control system is A Good Thing for software quality and developer productivity. Joel on Software goes as far as claiming it as the very first step on the path to writing good code.

Read the rest of this entry »

7 essential planning tips when developing your application on Facebook Platform

Posted by lee on February 11th, 2008

Once you have come up with a great idea for a Facebook application, seeing an idea all the way through its implementation can be a tricky business. Once you’ve figured out how the application is supposed to work, your design of the implementation - the strategy of how you will code up your app - is crucial to the success of your initial version.

When targeting the Facebook platform, it’s essential we consider the following seven items before we even begin to start coding:

  1. Access control integration
  2. Life cycle callbacks
  3. Friend tracking
  4. Notification map
  5. Invite/request positioning
  6. Advert usage/placement
  7. Your main logic!

To guarantee your app’s successful development, read on for tips and tricks about all of the above.

Read the rest of this entry »

Be strict with your FBML for Facebook notifications

Posted by lee on February 4th, 2008

The Facebook platform can be a very restrictive mistress at times.

The documentation for sending notifications states:

“The notification parameter is a very stripped-down set of FBML which allows only tags that result in just text and links.”

But they’re lying - it’s even more restrictive than that. At the time of writing, enclosing any text in <strong> tags will cause it to disappear from the notification! It’s unclear why developers are restricted from emaphisizing the important text in a notification. I mistakenly assumed basic stylings would be possible.

A cross-browser Windows Media Player component for ASP.NET 2.0

Posted by lee on February 4th, 2008

ASP.NET 2.0 is a very powerful, extensible web framework. Its component model allows for very efficient re-use of code and user interface designs.

As Microsoft created the entire framework, you might reasonably expect the default ‘Toolbox’ to offer you a wide range of components to integrate with other Microsoft technologies. Technologies such as Windows Media Player, MSN Messenger, Movie Maker or other client-side applications. Alas, this is not the case.

Read the rest of this entry »




© 2008 Crossbone Systems Ltd
Powered by Wordpress. Theme provided by Wordpress Themes - Absoluteshield Internet Eraser