Giter Site home page Giter Site logo

authlogic_facebook_connect's Introduction

Install and use

1. Install the facebooker gem and make Rails use it

$ sudo gem install facebooker

Make sure that you have setup you config/facebooker.yml to match your facebook application, make you application depended on the facebooker gem

config.gem "facebooker"

and run the xd_receiver generator to create the cross domain scripting bridge to make it possible for your application to communicate with facebook

$ script/generate xd_receiver

For more information on the facebooker gem checkout it’s readme github.com/mmangino/facebooker/tree/master

2. Install the Authlogic Facebook Connect plugin

$ script/plugin install git://github.com/kalasjocke/authlogic_facebook_connect.git

This plugin should soon be packed inside a gem.

3. Make some changes to your database

class AddFacebookConnectFieldsToUser < ActiveRecord::Migration
  def self.up
    add_column :users, :name, :string
    add_column :users, :facebook_uid, :integer, :limit => 8
  end

  def self.down
    remove_column :users, :facebook_uid
    remove_column :users, :name
  end
end

4. Make your layout look something like this

The important parts are the facebook html namespace, facebook javascript include and the facebook helper calls to init the facebooker gem.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
       "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml">
<head>
  <meta http-equiv="content-type" content="text/html;charset=UTF-8" />
  <title>Your awsome facebook connected app</title>

  <%= stylesheet_link_tag 'application' %>
  <%= javascript_include_tag :defaults %>

  <script src="http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php" type="text/javascript"></script>
</head>
<body>

<p style="color: green"><%= flash[:notice] %></p>

<%= fb_connect_javascript_tag %>
<%= init_fb_connect "XFBML" %>

<%= yield %>

</body>
</html>

5. Add the Facebook Connect button to your login form

<%= authlogic_facebook_login_button %>

Notes

If you want to save some user data when connecting to facebook you can use the before_connect hook in your user model.

def before_connect(facebook_session)
  self.name = facebook_session.user.name
end

For more information about what you can get form the facebook_session checkout the Facebooker gem rdoc.

authlogic_facebook_connect's People

Contributors

jcn avatar kalasjocke avatar mattenat avatar shadowfiend avatar szajbus avatar taweili avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.