Perl

From Facebook Developers Wiki

Jump to: navigation, search

Contents

[edit] Step 1: Install WWW::Facebook::API

[edit] Using the CPAN Module

  1. From the shell prompt: perl -MCPAN -eshell
  2. At the CPAN prompt: install WWW::Facebook::API

[edit] Installing with CPAN Without Root Access

CPAN normally tries to install a module system wide. If you're not a root user that will not work.

Read the instructions for Using CPAN Without Root.

[edit] Step 2: Setting up the Facebook App

[edit] Creating a new Application

Add the developer app, go to "My Applications", and create a new Application!

[edit] Callback URL

Should point to your script. Two examples:

Notice the trailing '/'. Using this method your entire application will all be in one script, and the script will decide what to show based upon what is following the .cgi

Using this method, you will need separate files for each canvas page, and your files will be index.cgi or whatever is set as the default in your .htaccess

[edit] Canvas Page URL

This should have something to do with your application. This is the address people will actually see when using your app.

[edit] Can your Application be added on Facebook?

Set this to yes if you want to have a box in the user's profile.

If you set this to yes, you can check "Developer Mode" further down so that only developers can install it (probably wise to enable during testing).

[edit] Step 3: An example program

The WWW::Facebook::API module contains an example CGI program for how to use it inside a Canvas, this can be obtained here. There are also several other examples of how to use the API in the examples directory (note the example links are updated to the version 0.4.7 API, but will presumably be quickly obsolete... dig into the latest version you find here if necessary).

For further API documentation see WWW::Facebook::API's POD.

[edit] Catalyst

[edit] WWW::Facebook::API Plugin

Catalyst::Plugin::Facebook provides a very simple wrapper around WWW:::Facebook::API and the documentation includes a simple method of preventing access to your application from non-Facebook users.

[edit] Example Usage

Somewhere in a controller:

$c->facebook->feed->publish_action_of_user( title => "My Title", body => "My Body", image_1 => 'http://myurl.com/static/fb.jpg', image_1_link => 'http://apps.facebook.com/myapp/link', );

[edit] Session Handling

The unreleased (on CPAN) module Catalyst::Plugin::Session::State::FcbkToken posted by Jim Spath on the Catalyst mailing list shows one method for creating a Facebook ::State plugin for the Catalyst::Plugin::Session module.

[edit] More

[edit] External links

For those that use Catalyst for writing their Facebook apps there is a page at the Catalyst wiki.