Installing Force for Facebook
Abstract
This document shows how to install the Force.com Toolkit for Facebook. The Toolkit is open source and hosted in a subversion repository on Google Code. After establishing a few prerequisites, we show how to install Subclipse, the Eclipse subversion plug-in, and then how to check the code out from the repository. Once you've done this, head over to one of the other documents in the Related Content section.
Prerequisites
Before proceeding to check-out the Force.com Toolkit for Facebook, please note that these instructions assume you have the Force.com IDE installed and are familiar with the basic functionality of Eclipse. If not, take some time to become familiar with both before proceeding to check-out the source code from the Google repository.
In addition, these steps require that you have installed the Eclipse plug-in that adds support for Subversion revision control system, also known as SVN. Because this is an important feature, please install the subclipse add-in and become familiar with the documentation it provides. If you have used SVN in the past, you may be able to install the subclipse add-in and proceed with the following steps.
Installing Subclipse
Follow the instructions here: http://subclipse.tigris.org/install.html
- Be sure to uncheck Integrations containing Buckminster and Subclipse Integration for Mylyn during the plugin installation.
- If this is the first time you have used SVN, please read the supporting documentation that comes with the Subclipse add-in.
Obtaining the Force.com Toolkit for Facebook
The next step is to select the source code to checkout.
Locating the Repository and Checking out the source code
Steps on checking out the source code:
- Create a new project in Eclipse and accept all the defaults.
- Go to Window > Open Perspective > Other and select SVN Repository Exploring
- Add a new repository: http://force4facebook.googlecode.com/svn/branches/force4facebook3_toolkit/
- Navigate to force4facebook3/src and right-click the folder.
- Go to export and enter the name of your new project when prompted for a project name.
- You will be asked to delete and overwrite the existing project. Accept this.
- Return to the Force.com IDE perspective and refresh your project to see the Force.com for Facebook items added to the project.
You should now have the Force.com Toolkit for Facebook source code in a new Eclipse project called "ForceToolkit4FB [trunk/ForceToolkit4FB]".
Activate Force.com Sites
- Go to Setup > Develop > Sites
- Create and register a Force.com Domain
- Click New to create a new site for this domain
- Enter a Site Label, such as 'FB Event Manager'
- Site Name will be autopopulated as 'FB_Event_Manager'
- Select your user account as a Site Contact
- Check the Active checkbox
- Keep the rest of the options on their default settings
Allowing Authentication of Users
In order to adhere to the Salesforce terms of service, we must use the Salesforce Customer Portal in order to authenticate users, rather than writing our own methods for user authentication.
- Go to Setup > Customize > Customer Portal > Settings
- Click Edit and check the Enable Customer Portal checkbox
- Click Cancel to skip the Customer Portal User Wizard
- Click Edit next to the newly created Customer Portal
- Ensure that Login Enabled is checked
- Set your user account to be the Administrator User
- Check the Self-Registration Enabled checkbox
- Set Default New User License to 'Customer Portal Manager'
- Set Default New User Role to 'User'
- Set Default New User Profile to 'Customer Portal Manager'
Creating Tabs for our New Objects
- Go to Setup > Create > Tabs
- Click New in 'Custom Object Tabs'
- Select GFCUser as the object
- Select any tab style
- Click Next and make the tab visible only for the 'System Administrator'
- Click Next and make the tab available only to the 'Force.com' app or any other app of your choosing
- Repeat for the Site Config object
Setting Up a Facebook Application
- Go to Facebook.com and login
- Add the Developer application to your Facebook account
- Click on Setup New Application within the Developer application
- Give it a name. Keep in mind you can't use 'Facebook' or any variation of that word in the name of your application
- Make note of your API Key and Secret, you will need these in Salesforce
- Click on the Connect item in the sidebar and set your Connect URL to the domain of your Force.com Site (http://sitename-developer-edition.na7.force.com)
- Click on the Advanced menu item and ensure that the Application Type is set to 'Web'
- Click Save Changes
Set Up a Portal User
- Go to the Accounts tab
- Create a new account with the name of 'Facebook Portal' and any basic information you desire
- Now we must setup role for the owner of the Portal User Account
- Click on the Account Owner
- Give the User a role. It can be any role.
- Return to the Account and retrieve the Salesforce ID for the record from the end of the URL
- Now we can add the Portal User Account Salesforce ID to the Force.com Site
- Return to the Force.com IDE
- Find the SiteRegisterController class
- Change the following line to include your Account ID
- private static Id PORTAL_ACCOUNT_ID = 'xxxxxxxxxxxxxxx';
- Save the class
Set Up the Site User
- Go to the Site Config tab you created earlier
- Create a New record for 'Site Config'
- Enter the Site Name as it is found in your Force.com Sites configuration, in this case: 'FB_Event_Manager'
- Enter the API Key from your Facebook developer application
- Enter your Facebook Application Secret
- Lookup the Portal User Account that you created earlier
- Save the record
Configuring Remote Site settings
- Go to Setup > Security Controls > Remote Site Settings
- Click New Remote Site and enter the following for each field
- Remote Site Name: FacebookAPI
- Remote Site URL: http://api.new.facebook.com
- Check Disable Protocol Security
- Click Save & New
- Remote Site Name: FacebookAPISSL
- Remote Site URL: https://api.new.facebook.com
- Leave Disable Protocol Security unchecked
- Save the record
Setup Proper Permissions
- Go to Setup > Create > Objects
- Click Edit on 'GFC User'
- Under Optional Features, select the Available for Customer Portal checkbox
- Repeat for the 'Site Config' object
- Go to Setup > Manage Users > Profiles
- Click on the Customer Portal Manager profile so we can grant access to our two new objects
- Click the Clone on the profile
- Enter a new Profile Name, such as 'Facebook Portal User'
- Click Edit on the new 'Facebook Portal User' profile
- Scroll down until you see the Custom Object Permissions
- Set GFC Users to Read, Create, Edit
- Set Site Configs to Read
- Return to the 'Facebook Portal User' profile
- Click Edit on the 'Enabled Visualforce Page Access' related list
- Move the following pages over to the Enabled Visualforce Pages section: MyFacebookSiteLogin, MyFacebookSiteTemplate, MyFacebookUnauthorized, MyHomePage, MyOtherProtectedPage, MyProtectedPage, MyFacebookCss, xd_receiver
- Click Save
- Now because we cloned the profile, we must go back to the Customer Portal Setup to update the default user profile
- Go to Setup > Customize > Customer Portal
- Click Edit on your Customer Portal
- Under the Self-Registration Settings, change the Default User Profile to 'Facebook Portal User'
- In the 'Assigned Profiles' related list, click Edit Profile and check 'Facebook Portal User'. You can uncheck the old profile
Setup Login Settings for Your Force.com Site
- Go to Setup > Develop > Sites
- Click into your Site and click on Login Settings
- Click Edit and change Login to 'Enabled for Customer Portal'
- Leave the other settings to their defaults and click Save.
- Click on the Public Access Settings button on your Site to view the Guest License Profile ('FB Event Manager Profile' in this example)
- Click Edit and find the Custom Object Permissions section
- Check all the boxes for GFC User
- Check 'View All' and 'Read' for Site Configs
- Edit the Enabled Visualforce Pages
- Move the following pages over to Enabled Visualforce Pages: MyFacebookSiteLogin, MyFacebookSiteTemplate, MyFacebookUnauthorized, MyHomePage, MyFacebookCss, xd_receiver
- Click Edit and find the Custom Object Permissions section
Setup New Facebook Home Page
- Go to Setup > Develop > Sites and click into your Site
- Change Active Site Home Page to 'MyHomePage'
- Change Site Template to 'MyFacebookSiteTemplate'
Congratulations, You're Done!
- Navigate to your Force.com Site URL and you should see the included example (MyHomePage) load as the home page
- Try it out by logging in with Facebook Connect

