Facebook

This is a short guide to creating a robot which accesses Facebook through the Graph API. The Graph API is the API used to read and write to Facebook accounts. See https://developers.facebook.com/docs/reference/api/ for more information.

First, log into http://developers.facebook.com with your Facebook account, or create a new account if necessary. Click "Apps" in the bar at the top of the page.

Then, click "Create New App".

Type in a name for the new app and click Continue.

A configuration screen now appears for the new app. One of the fields is called App Domains and is used to state any domains used by the app. This must be set to the domain which hosts the Management Console. If running with an embedded Management Console write "localhost" in this field. At the bottom of the page it is possible to select how the app integrates with Facebook. Choose "Website with Facebook Login" and write the OAuth callback URL as Site URL. The callback URL is the path OAuthCallback under the folder in which the Management Console is deployed. For instance, if running with an embedded Management Console, it runs at http://localhost:50080/. In this case, the callback URL would be specified to http://localhost:50080/OAuthCallback.

On this page it is also important to take note of the App ID and App Secret which will be used as Consumer Key and Consumer Secret in the Management Console later on.

After saving the basic configuration of the app, go to the Permission Configuration by clicking "Permissions" in the menu on the left side of the page. Here it is possible to configure which permissions the app requires when being authenticated. For basic user information type "user_about_me" in the "User & Friend Permission" field. For more information on the possible permissions, please visit https://developers.facebook.com/docs/reference/login/.

Once the app has been set up and any permissions have been saved, open the Management Console. Make sure to open the Management Console at the URL specified for the app. That would be http://localhost:50080 for the information used above. Then navigate to the OAuth Repository and click "New Application".

Select a name for the new application and choose Facebook as the service provider. Consumer Key and Consumer Secret should respectively be set to the App ID and App Secret noted earlier. The Callback URL should already be correctly stated.

After being saved, the application appears in the repository. Click on the icon under "Add User" to add a user to the application.

Choose a name for the user and click next.

Now, click the authorization link.

This will open a page where the app will request permission to access your Facebook account.

Authorizing the app will forward you to the OAuth callback page of the Management Console.

Close the OAuth callback page, returning to the Management Console. Click Next in the wizard and you will see the access token that can be used for accessing Facebook on the user's behalf. Copy this token into a notepad since it for security reasons not will be accessible later.

After clicking Finish, you should now see a user in the Users section of the OAuth tab.

Now, open Design Studio and create a new robot or open the robot you would like to access the Facebook API. For the robot to be able to use the Facebook Graph API, make sure that it has an input variable of the complex type "OAuthCredentials" which contains "Facebook" as the service provider name and the Access Token copied from the Management Console earlier.

Then, make sure to configure the robot to use OAuth credentials.

The robot should now be able to access the Facebook Graph API. As an example try typing https://graph.facebook.com/me in the address bar of the browser view and press Enter.

To learn more about the Facebook Graph API visit https://developers.facebook.com/docs/getting-started/graphapi/. Once a robot has been built, it is possible to schedule execution of the robot in the Management Console.