32
WELCOME TO RUBY ON RAILS DEVELOPERS

Connect with Facebook to Rails Application By Nyros Developer

Embed Size (px)

DESCRIPTION

Connect with Facebook to Rails Application

Citation preview

Page 1: Connect with Facebook to Rails Application By Nyros Developer

WELCOME TO

RUBY ON RAILS DEVELOPERS

Page 2: Connect with Facebook to Rails Application By Nyros Developer

An introduction to Facebook Connect

Nyros Facebook Developer Garage,May 29th 2010

Page 3: Connect with Facebook to Rails Application By Nyros Developer

Requirements for facebook integration

Facebooker Gem Facebooker Plugin Facebook Login Details Facebook Developer Application

Page 4: Connect with Facebook to Rails Application By Nyros Developer

Introduction Uses in real time Implementation & Integration with Rails

App

Page 5: Connect with Facebook to Rails Application By Nyros Developer

Facebook Connect - Introduction

What Facebook Connect does:• Allow your friend network information to be

brought to external websites• Allow external website activity to be brought

into Facebook Both aspects top priority for Facebook.

Page 6: Connect with Facebook to Rails Application By Nyros Developer

• Traffic

Enable over 300MM Facebook users to share your content with their friends on Facebook

• Engagement

Users can immediately find their friends and engage(add as friend).

• Revenue

Boost your revenue. Facebook Connect helps you grow revenue by increasing traffic and user engagement. In addition, better targeting capabilities can improve monetization.

Facebook Connect - Introduction

Page 7: Connect with Facebook to Rails Application By Nyros Developer

Use in real time

Scribd is a document-sharing website

Page 8: Connect with Facebook to Rails Application By Nyros Developer
Page 9: Connect with Facebook to Rails Application By Nyros Developer

Use in real time

Page 10: Connect with Facebook to Rails Application By Nyros Developer

Use in real time

Page 11: Connect with Facebook to Rails Application By Nyros Developer

News feed in our FB friends wall

Page 12: Connect with Facebook to Rails Application By Nyros Developer

Implementation & Integration with Rails App

• Create Rails Application• c:\> rails connect_facebook• c:\> gem install facebooker • c:\>ruby script/plugin install

git://github.com/mmangino/facebooker.git or download from github

http://github.com/mmangino/facebooker• Plugin placed at • connect_facebook\vendor\plugins

Page 13: Connect with Facebook to Rails Application By Nyros Developer

Implementation & Integration with Rails App

• Steps for create facebook application• http://www.facebook.com/developers/createa

pp.php

Page 14: Connect with Facebook to Rails Application By Nyros Developer
Page 15: Connect with Facebook to Rails Application By Nyros Developer
Page 16: Connect with Facebook to Rails Application By Nyros Developer
Page 17: Connect with Facebook to Rails Application By Nyros Developer

Take a note of the api_key and secret and add these to config/facebooker.yml

Page 18: Connect with Facebook to Rails Application By Nyros Developer

development: api_key: 23ad2f3a4cf6f235b2249dd0138c2913 secret_key: d3570fc4434b5a4ad9e1fc0f29e991c3 canvas_page_name: callback_url: http://localhost:3000/ pretty_errors: true set_asset_host_to_callback_url: true tunnel: public_host_username: public_host: public_port: 4007 local_port: 3000

add these api and secret keys to config/facebooker.yml

Page 19: Connect with Facebook to Rails Application By Nyros Developer

• Javascript tags include at application layout <%= javascript_tag "window.xd_receiver_location =

'#{ENV['XD_RECEIVER_LOCATION']}';" %>

<%= javascript_include_tag 'facebook_require' %> <%= javascript_include_tag 'http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php' %>

or register with Facebook connect <fb:login-button onclick='facebook_button_onclick()'></fb:login-button>

Page 20: Connect with Facebook to Rails Application By Nyros Developer

Some Connect code:<fb:login-button> </fb:login-button><script src="http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php" type="text/javascript"></script>

This loads in the JavaScript library which renders the login button

Page 21: Connect with Facebook to Rails Application By Nyros Developer

• c:\> ruby/script/generate xd_receiver• xd_receiver is a cross-domain receiver file

Two different methods for login, in this implementation

Page 22: Connect with Facebook to Rails Application By Nyros Developer

• Create controllerc:\> ruby script/generate controller fb_connect

def authenticate

set_facebook_session

@facebook_session = Facebooker::Session.create(Facebooker.api_key, Facebooker.secret_key)

logger.debug "facebook session in authenticate: #{facebook_session.inspect}"

#render :text=>set_facebook_session and return

redirect_to @facebook_session.login_url

end

Page 23: Connect with Facebook to Rails Application By Nyros Developer

Enter here out facebook login details

Page 24: Connect with Facebook to Rails Application By Nyros Developer

A Facebook styled dialogue box lets the user know what’s going on

Page 25: Connect with Facebook to Rails Application By Nyros Developer
Page 26: Connect with Facebook to Rails Application By Nyros Developer

What you can do when you’re “Connect”ed:• Display information from Facebook profiles on

your own site• Publish stories to Facebook from your site• Re-create your users’ social graphs

Page 27: Connect with Facebook to Rails Application By Nyros Developer

Facebook Connect – How it works

Quick tech intro:• Uses an evolved version of the JavaScript client

library:• Use FBML within your standard HTML. (They call

this XFBML.)• Make standard Facebook API calls within the

JavaScript library• Facebook’s JavaScript XFBML library populates

FBML tags on your site with profile data

Page 28: Connect with Facebook to Rails Application By Nyros Developer

What you can’t do:• Publish stories to a friends newsfeed, only to

the current user’s• Update any profile box except that of the

current user

Page 29: Connect with Facebook to Rails Application By Nyros Developer

Facebook Connect – Disadvantages

There are disadvantages to Facebook Connect…

Page 30: Connect with Facebook to Rails Application By Nyros Developer

Facebook Connect – Disadvantages

It’s all in JavaScript:• Not always the most manageable code• Takes some lateral thinking to hook up with

your site’s databases• No SEO benefits• Poor accessibility (JavaScript disabled =

Facebook Connect doesn’t work)

Page 31: Connect with Facebook to Rails Application By Nyros Developer

Facebook Connect – Disadvantages

It’s not a treasure-trove of new user details:• Can’t access any more friend details than if a

user adds an application i.e. no access to e-mail addresses

• Facebook intends privacy settings to be dynamic, therefore changes in Facebook settings may affect your site

• You don’t own the data

Page 32: Connect with Facebook to Rails Application By Nyros Developer

Facebook Connect – The future

ThanksRatnam Raju, [email protected]