October 21, 2014
Hot Topics:
RSS RSS feed Download our iPhone app

Writing Facebook Applications Using Java EE

  • March 13, 2008
  • By PJ Cabrera
  • Send Email »
  • More Articles »

Follow these steps to fill out the "New Application" page with basic values:

  1. Fill the "Application Name." This is what you want your application to be known as among users. Facebook will use this name when reporting user activity with your app on users' "Mini Feed."
  2. Read the "Terms and Conditions" and check the checkbox if you agree with them.
  3. Click the link named "Optional Fields" to open the form up and show the other fields.

The next fields are optional for the simplest of Facebook apps, but for most types of applications, you want to fill out at least "Callback URL" and "Canvas Page URL" and leave the rest at their default values. Without those two fields filled, you can only create a so-called external Facebook app. External Facebook apps can only be accessed from a domain different from *.facebook.com, but the app can still access Facebook users' social network information through the API.

  1. In the two e-mail fields, you can enter your e-mail address, but they can be blank during development.
  2. The "Callback URL" field needs to be filled with the base path URL to your application on your development server. All application actions and pages are relative to this URL.
    • What you enter here is specific for your own setup, but to be clear, you should not put "http://localhost:8080/myfacebookapp". This needs to be an address that Facebook servers can reach through the Internet, not a local network address. This means that if you are following along from home, developing on your home computer, you need to find what your external IP address is, and open your application server's HTTP port in your firewall. This is fine for at-home development and experimentation with the API, but you will need to find a hosting solution for "going live" with your Facebook applications.
    • This URL needs to have a servlet or web framework action mapped to it, with the URL pattern set to the root of the web app ("/" or the slash.) We will do this for our example later on.
  3. The "Canvas Page URL" refers to the base path URL on the apps.facebook.com subdomain where users go to access your app. All application actions and pages are relative to this URL.
  4. For this introduction, you will choose FBML as your application's rendering method.
    • Whether you choose to have your application rendered as an FBML canvas or iframe canvas is a matter of whether you will be using a lot of JavaScript effects, Ajax or Flash in your application's user interface (iframes), or whether you want to follow the Facebook look and feel as closely as possible with minimal effort (FBML.)
    • JSF, Facelets, and Tapestry developers should select iframe rendering.
  5. Select no to indicate your application can be added on Facebook. Selecting "yes" would mean the app will show on your users' profiles, helping your app spread as other users see information about your app on their friends' profiles. This is great once you are live, but you will turn it off during development.
  6. You can leave the Terms of Service URL blank for now.
  7. If you are developing the app with the help of other Facebook users, you can add them to the "Developers" field.

Now that the fields have been filled as outlined above, you can click "Submit." Facebook Developer App will take your input and take you to a page listing the apps you have registered with Facebook. Below your application's name, you will see an API key and a secret key for your application. Make note of these hex strings; you need them later when calling into the Facebook API.

Figure 4: Facebok's Developer App, showing the newly created app's details (blacked in my example)

Preparing the Development Environment

Throughout the rest of the article, I will be using the Eclipse Web Tools Platform, Apache Tomcat 5.5 application server, and XDoclet 1.2.3. Setting up Eclipse and the Web Tools Platform plugin, XDoclet, and Tomcat is beyond the scope of this particular article. That said, if you have never used Eclipse before and want to work through this article with a minimum of fussing around with Eclipse, I recommend you download the EasyEclipse Server Java distribution of Eclipse and web development plugins, available at http://www.easyeclipse.org/site/distributions/server-java.html . You will still need to download and install Tomcat and XDoclet separately and set up Eclipse Web Tools Platform to work with them.

Once you have your development environment properly set up, create a new Dynamic Web Project called myfacebookapp by clicking the drop-down arrow next to the "New" button on the extreme left side of the Eclipse toolbar. Then, select "Project." When the "New Project" dialog box appears, select "Dynamic Web Project" from the "Web" project category. Then, click the "Next" button.

Figure 5: The "New" button pulldown menu, with "Project" selected


Tags: Facebook



Page 2 of 7



Comment and Contribute

 


(Maximum characters: 1200). You have characters left.

 

 


Sitemap | Contact Us

Rocket Fuel