Facebook application

From StatusNet

Jump to: navigation, search

Contents

[edit] Setting up StatusNet's built-in Facebook application

Image(facebook-app.jpg, 300px)

StatusNet's Facebook application allows the users of your instance to automatically update their Facebook statuses with their latest notices, invite their friends to use the app (and thus your site), view their notice timelines, and post notices -- all from within Facebook. The application is built into StatusNet and runs on your host. Facebook makes HTTP calls to it and uses the return data to render pages for the application inside Facebook.

There are two steps to getting StatusNet's Facebook application up and running for your StatusNet install.

1. Create a new Facebook application (with your Facebook account) using the Facebook Developer Application, and configure it to point to your installation of StatusNet. 1. Setup a cron job on your system to run the update_facebook.php script, located in the scripts/ directory of your StatusNet installation.

Note: As of Laconica 0.7.2 (now StatusNet) the cron job script is deprecated, and automatic updating of Facebook statuses is accomplished via StatusNet's queueing system just like SMS, XMPP, etc., through a FacebookQueueHandler, so you will need to enable queuing and run the queue daemons if you want to use the built-in Facebook application.

[edit] Step 1

[edit] a)

Install the Facebook Developer Application (if you haven't already done so).

http://www.facebook.com/developers/

[edit] b)

Start the Developer Application and setup a new application (there's a button).

Facebook will generate a new API key and secret for you, and redirect you to its application editor where you to configure your application. The API key and secret are strings of random alphanumeric character that you will need copy and paste into the Facebook section of your StatusNet instance's config.php file.

For example: if your Facebook API key is "8b5e1ba4a5fbef3addeeca472bfe7dda" and your secret is "2f8986fdeb6f031025d2b8d07a33f10f" the Facebook configuration section of your config.php should look like this:

# config section for the built-in Facebook application
$config['facebook']['apikey'] = '8b5e1ba4a5fbef3addeeca472bfe7dda';
$config['facebook']['secret'] = '2f8986fdeb6f031025d2b8d07a33f10f';

(Don't forget to uncomment the lines as well.)

EDIT 1/22/11 by George D.

You also need to add to config.php:

addPlugin('Facebook');

[edit] c)

The Facebook application editor has a vertical tabbed navigation menu. Here are the settings you'll need for each tab:

[edit] Basic Tab

Image(basic.jpg, 300px)

  • Set your "callback URL". The callback URL is the most important URL to get right as it's used by Facebook to build all of the requests to StatusNet, which are relative. It should be your StatusNet installation's URL with "/facebook/app/" appended. So if the URL for your instance of StatusNet is http://laconicats.org/ then your callback URL will be (don't forget the trailing slash): http://laconicats.org/facebook/app/

UPDATE 05/29/09 - Facebook has moved the callback URL to the 'Canvas' tab, under 'Required URLs,' and renamed it to 'Canvas Callback URL' You have to set this URL correctly, or the Facebook App will not work at all!

  • On the "Basic" page, you can also set a description, contact information, and URLs to web pages for your application's Help, Privacy, and Terms of Service. None of the other URLs are needed to get your Facebook application running, but may be necessary to get it listed in Facebook's application directory.

[edit] Authentication tab

Image(authentication.jpg, 300px)

  • For the "Who can use your application?" question check the checkbox for users.
  • The next thing to worry about is your application's Post-Remove Callback URL. The linkage between Facebook users and StatusNet users is stored in StatusNet, and the Facebook application needs to delete the link if a user decides to uninstall the Facebook app from his or her Facebook account. That's done by making a request to StatusNet. The Post-Remove URL should be set to your StatusNet installation's URL with "/facebook/remove" (no extension) appended. E.g.: http://laconicats.org/facebook/remove
  • Leave the other fields blank.

[edit] User Profiles

  • You can ignore the stuff on this tab.

[edit] Pages

Image(pages.jpg, 300px)

  • Set the Post-Add Redirect URL to http://apps.facebook.com/ + the name of your application + Let's say you're calling your app "laconicats" then your Post-Add Redirect URL will be: http://apps.facebook.com/laconicats/

[edit] Canvas

Image(canvas.jpg, 300px)

  • Set the Canvas Page URL to be the same as your Post-Add Redirect URL.
  • Also set the Bookmark URL to be the same as your Post-Add Redirect URL.
  • In the "Canvas setting" section, choose the "FBML" for Render Method, "Smart Size" for IFrame size, and "Full width (760px)" for Canvas Width.

[edit] Connect Tab

  • Ignore the stuff on the Connect tab.

[edit] Advanced Tab

Image(advanced.jpg, 300px)

  • Choose "Web" for Application type.
  • Initially you may want to enable "Sandbox Mode" while your testing, which restricts those who can use the application to you and your Facebook friends you add as "Developers", but once you're satisfied that you have the application configured and working well, you will want to select "Disable".
  • Every other configuration option can be left with its default setting.

[edit] Step 2

Step two is getting the cron script to run. The script looks for new notices posted by your users and updates their Facebook statuses accordingly.

The script needs to be able to write to the scripts directory. It might be easiest to run the script as the root user if you can. Here is a sample cron job for Ubuntu Linux (for /etc/crontab) that runs the script once per minute and sends all output to a log file.
# config section for the built-in Facebook application
$config['facebook']['apikey'] = '8b5e1ba4a5fbef3addeeca472bfe7dda';
$config['facebook']['secret'] = '2f8986fdeb6f031025d2b8d07a33f10f';
 http://laconicats.org/ 
http://laconicats.org/facebook/

http://laconicats.org/facebook/remove
 http://apps.facebook.com/ 
http://apps.facebook.com/laconicats/
 scripts/update_facebook.php 
# config section for the built-in Facebook application
$config['facebook']['apikey'] = '8b5e1ba4a5fbef3addeeca472bfe7dda';
$config['facebook']['secret'] = '2f8986fdeb6f031025d2b8d07a33f10f';
 http://laconicats.org/ 
http://laconicats.org/facebook/

http://laconicats.org/facebook/remove
 http://apps.facebook.com/ 
http://apps.facebook.com/laconicats/
 scripts/update_facebook.php 
# m h dom mon dow command
* * * * * /usr/bin/php /var/www/laconicats/scripts/update_facebook.php >> /var/log/fbupdate.log 2>&1

Note: As of Laconica 0.7.2 (now StatusNet) the cron job script is deprecated (see the first section of this document).


Personal tools