connect with facebook to rails application by nyros developer
DESCRIPTION
Connect with Facebook to Rails ApplicationTRANSCRIPT
WELCOME TO
RUBY ON RAILS DEVELOPERS
An introduction to Facebook Connect
Nyros Facebook Developer Garage,May 29th 2010
Requirements for facebook integration
Facebooker Gem Facebooker Plugin Facebook Login Details Facebook Developer Application
Introduction Uses in real time Implementation & Integration with Rails
App
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.
• 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
Use in real time
Scribd is a document-sharing website
Use in real time
Use in real time
News feed in our FB friends wall
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
Implementation & Integration with Rails App
• Steps for create facebook application• http://www.facebook.com/developers/createa
pp.php
Take a note of the api_key and secret and add these to config/facebooker.yml
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
• 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>
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
• c:\> ruby/script/generate xd_receiver• xd_receiver is a cross-domain receiver file
Two different methods for login, in this implementation
• 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
Enter here out facebook login details
A Facebook styled dialogue box lets the user know what’s going on
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
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
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
Facebook Connect – Disadvantages
There are disadvantages to Facebook Connect…
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)
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
Facebook Connect – The future
ThanksRatnam Raju, [email protected]