A simple facebook connect library for ruby
Go to file
W. Andrew Loe III 0937d2ba9d Merge branch 'master' of http://github.com/mixr/facebooker2
* 'master' of http://github.com/mixr/facebooker2:
  - the async call needs to load into the body, otherwise FB.ui doesn't work in "dialog" mode - facebook also recommends loading into the front of the body:   http://developers.facebook.com/docs/reference/javascript/FB.init
  added methods fb_concat and fb_html_safe   -> use concat or not, depending on rails version   -> use html_safe when available
  fixed version check
  make fb_connect_async_js return a html_safe string for rails 3
  use :locale parameter in options to set locale of fb-connect javascript assets

Conflicts:
	lib/facebooker2/rails/helpers/javascript.rb
2010-08-24 01:00:51 -07:00
lib Merge branch 'master' of http://github.com/mixr/facebooker2 2010-08-24 01:00:51 -07:00
spec Add handling for params 2010-07-22 15:55:52 -04:00
facebooker2.gemspec Add handling for params 2010-07-22 15:55:52 -04:00
init.rb initial import 2010-05-04 12:30:49 -04:00
MIT-LICENSE initial import 2010-05-04 12:30:49 -04:00
Rakefile initial import 2010-05-04 12:30:49 -04:00
README only need a logout link when you are logged in 2010-07-27 08:54:15 -04:00

Facebooker2
===========

Provides rails helpers for interfacing with Facebook's OpenGraph Javascript
API, http://developers.facebook.com/docs/reference/javascript/.

Requires the mogli gem.


Example
=======

0. Prerequisite: You need a facebook app.  Have your API Key, Application
Secret, and Application ID handy.

1. Install facebooker2 as a plugin in your rails app.

2. Create config/facebooker.yml with the appropriate environment.

production:
  app_id: <your application id>
  secret: <your application secret>
  api_key: <your application key>

3. Create config/initializers/facebooker2.rb and place the following line in it

Facebooker2.load_facebooker_yaml

4. Add the following line to your app/controllers/application_controller.rb

include Facebooker2::Rails::Controller

5. Update your rails applications to use the rails helpers.  This could be in a
shared login partial.

<%= fb_connect_async_js %>
<% if current_facebook_user %>
   <%= "Welcome #{current_facebook_user.first_name} #{current_facebook_user.last_name}!" %>
   or 
   <%= "Hello #{fb_name(current_facebook_user, :useyou => false)}!" # link to facebook profile
    %>
  <%= fb_logout_link("Logout of fb", request.url) %><br />
<% else
   # you must explicitly request permissions for facebook user fields.
   # here we instruct facebook to ask the user for permission for our website
   # to access the user's facebook email and birthday
   %>
  <%= fb_login_and_redirect('<your URL here>', :perms => 'email,user_birthday') %>
<% end %>

Copyright (c) 2010 Mike Mangino, released under the MIT license