Writing Facebook Applications Using Java EE, Page 2
Follow these steps to fill out the "New Application" page with basic values:
- 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."
- Read the "Terms and Conditions" and check the checkbox if you agree with them.
- 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.
- In the two e-mail fields, you can enter your e-mail address, but they can be blank during development.
- 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.
- JSF, Facelets, and Tapestry developers should select iframe rendering.
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
Page 2 of 7