Wednesday, June 20, 2007

Getting Started with the Facebook Platform API

In this three-part tutorial you'll learn how to:
  • Add the Developer Application to your Facebook account
  • Setup Java Client Library in Eclipse IDE
  • Use the Facebook Platform API

1. This screencast shows how to create a Facebook Platform application that you can use as a template for your own Facebook applications.(03:35):

2. In order for a Facebook API client to use the API, the user of the client application must be logged in to Facebook. This screencast describes typical scenarios using a simple Java Servlet. (04:15):

3. This screencast tutorial shows how to use the Facebook Platform API in an example that uses data about logged Facebook user and his friends. (03:25):

For this tutorial we have used materials from:

1): Facebook Developers Documentation

Recommended books:
Eclipse Web Tools Platform: Developing Java(TM) Web Applications Core Servlets and JavaServer Pages, Vol. 1 Core Servlets and Javaserver Pages: Core Technologies, Vol. 2

If you are interested in more Facebook platform screencasts, please leave a comment.


Anonymous said...

very nice, and really helpful.

Anonymous said...

A very functional Application found at Facebook. It was created by CNET Networks.

Facebook Link:

Blog post

Anonymous said...

Wicked, can we have some more like this. Maybe showing how to send application to friends, or giving examples like the zombie application

Anonymous said...

It's just wonderful. I've followed this and made a simple application successfully. Thanks

Anonymous said...

Thank you. That was very helpful. It was a great facebook and eclipse lesson.

Matt said...

In the last example, the code that displays the number of friends for the logged in user is incorrect. Check out tip #4 on this site to correct it:

Anonymous said...

Very Nice - keep em coming - would like a demo showing how to create all the different components of a facebook app with java!

Md. Afzalur said...

This is a great tutorial. It has everything to start with. Near future please do the same for struts application. I am also planning to be beside you soon.

Thanks & Regards,
Md. Afzalur Rashid

Anonymous said...

very nice application check my blog for struts

Anonymous said...

Awesome tutorial. The Struts idea is a good one or if you could give an example of a Facebook app that runs right in Facebook

Md. Afzalur said...

Dear Friends,
I am working with struts Facebook application. Hope can share my knowledge with you soon. I need places to upload my application which supports java application. Can any one hel me regarding java webhosting.
Thanks& Regards,
Md. Afzalur Rashid

diibanez said...

You can try with

They provide you free java hosting and a MySql instance to do some initial testing.

Anonymous said...

This is a great jumpstart.
IMHO, there should be a link to this in Facebook developer Resources.


AmitKumar Agrawal said...

Kudos for your great work....Really this is great screencast... I was looking for it. It will be very helpful if you can send more functional application to me or can post somewhere. Please update me ( .

Thanks & Regards
Amit said...

Thanks! Another Facebook screencast is in pipeline. Stay tuned!

Matt said...

I was getting a problem because of the version number, not really sure why.

I got the error message "invalid API Key" so i changed the last line to...

response.sendRedirect("" + apiKey);

(but i wouldn't trust me because i still haven't got it working...!)

Anonymous said...

I keep getting an javax.servlet.ServletException: org/apache/commons/el/ExpressionEvaluatorImpl exception from the line:

request.getRequestDispatcher("info.jsp").forward(request, response);

anyone got any ideas why?


Chris said...

Excellent stuff. Well done.
I would love to see a more functional example of implementing Facebook components, e.g. invite friends etc.
This would be extremely beneficial to those starting out.

Farhan Thawar said...

Good stuff... thanks

Amarsh said...

Great work. Facebook itself is extremely limited in its documentation.
An interesting open source project to wrap the Facebook API to a more meanigful one is at

Yagiz said...

Excellent work! Thanks a lot!

dara_masala said...

Great tutorial.

Anonymous said...

Hi Guys i am trying out this example.

facebookRestClient = new FacebookRestClient(apiKey, secretKey, sessionKey);

i am getting an error
"cannot instantiate the type FacebookRestClient" for the above instantiation statement.

can somebody help me on this.


Anonymous said...

Its very good tutorial.

koteswara said...


facebookRestClient has to be replaced with facebookXmlRestClient otherwise it will show an error message "facebookRestClient cannot be instantiated".

Anonymous said...

Thanks a lot, I was finally able to get started using the Facebook platform thanks to these great tutorial.

Keep up the good work.

Arun said...


The post is excellent. Could you point me to links on how to integrate a facebook application into a web page. I heard that they recently made a java client library available to do that.

ihvan said...

ty for this trutorial. it is what i was looking for.


Lasantha said...

excellent! that's all i could say.

Anonymous said...

Excellent work .. good way to demonstrate and explain facebook applications

Anonymous said...

hi, I'm new to facebook. Ur sample helped me to just try but the API u have used is no longer supported by facebook.

How to do it in facebook Connect?

AH said...

Excellent series. You may want to update it with FaceBook Connect. Great job. Thanks for sharing it with us.