SlideShare uma empresa Scribd logo
1 de 21
Baixar para ler offline
Facebook Connect Tutorial

       Prateek Dayal

        Muziboo.com


       Mar 7th, 2010
Resources




      Code: http://github.com/prateekdayal/fb-tutorial
      This Presentation: http://www.slideshare.net/prateek.
      dayal/facebook-connect-tutorial
      FB Connect’s Docs:
      http://developers.facebook.com/connect.php
Setting up a New App




      Install the ’Developer App’ in Facebook
      Create a new application (in fact two: one for production and
      the other for testing)
      The canvas callback url should point to your website (or your
      dev machine)
SSH Tunnel Setup




      Problem: You need to access your dev machine over the
      internet and you don’t have a public IP
      Solution: Use a ssh tunnel
      On Linux machines
          In /etc/ssh/sshd config put GatewayPorts yes
          Restart the ssh server prateekdayal: # /etc/init.d/ssh
          restart
Starting the Tunnel on localhost




       Lets assume that you want to forward the local port 3000 to
       port 3333 on your server (ex: prateekdayal.net)
       prateek@marvin: /work/talks/acm$ ssh
       prateek@prateekdayal.net -gNR 3333:localhost:3000
       You can now access http://localhost:3000 at
       http://www.prateekdayal.net:3333
Cross Domain Receiver File



      Problem: Ajax calls from your domain to Facebook.com and
      passing data from Facebook.com to your domain
      Solution: Cross Domain Receiver File
      A technique for passing data between different domains
      Used for detecting login status, setting fb cookies on your
      domain etc
      You can get the file from Facebook’s Dev site
      You have to place it relative to the root directory of your app
      <site root>/xd receiver.html
Lets build a quick app




   Objective: Comment on a blogpost with your Facebook ID and
   post the comment on your news feed
Creating the Login page



         File: public/fb-connect.html
         Include FB Connect’s Javascript code
         I have also included prototype.js to make manipulate the
         DOM more easily
         Add a form and ’Login with Facebook’ button
         Add the JS code to render fbml tags   1




     1
       http://wiki.developers.facebook.com/index.php/Connect/
   Authorization_Websites
Show User Info




         File: public/fb-connect-show-info.html
         Use XFBML tags to show name and profile pic   2

         Also provide a Logout button   3




     2
       http://wiki.developers.facebook.com/index.php/XFBML
     3
       http://wiki.developers.facebook.com/index.php/Logging_Out_
   And_Disconnecting
Detecting the Login State



         File: public/fb-connect-detect-login-state.html
         Problem: Every time we refresh the page we have to login
         again
         Solution: Pass ifUserConnected and ifUserNotConnected
         options to FB Connect’s init function 4
         Remove the separate handlers for login & logout
         This can be used to automatically login users if they are
         logged into FB (single sign-on)




     4
       http:
   //wiki.developers.facebook.com/index.php/Detecting_Connect_Status
Posting to News Feed




         File: public/fb-connect-feed-story.html
         We can use FB.Connect.streamPublish to publish to News
         Feed 5
         FB allows pictures, mp3, flash etc to be attached to the feed




     5
       http://wiki.developers.facebook.com/index.php/Implementing_
   Feed_Publishing_from_your_Website_or_Application
Server side stuff


       Problem: You want to let users login with FB and connect
       existing accounts
       Solution: Read cookies set by FB (on your domain) to get
       user id and session id
       FB User ID can be used to identify the user on next login and
       connect with your auth system
       Session ID can be used to make FB API calls (to fetch
       detailed user info etc)
       Php, Ruby on Rails and other languages have libraries
       available to make all this easy
Advanced Features




      Extended session permission
      Ask for user’s primary email address
      Friend recommendation and invitation
A note on Platform Policies




          Most of the data (including name) cannot be cached for more
          than 24 hours
          If a user de-authorizes your app, you need to delete data
          received by API (and not direct submission)
          Many more guidelines   6




     6
         http://wiki.developers.facebook.com/index.php/Storable_Data
Questions?




      prateek@muziboo.com
      @prateekdayal
      http://www.prateekdayal.net
      http://devblog.muziboo.com

Mais conteúdo relacionado

Mais procurados

Facebook Open Graph Tech Requirements
Facebook Open Graph Tech RequirementsFacebook Open Graph Tech Requirements
Facebook Open Graph Tech Requirements
Affinitive
 
Uk Nuke Facebook Connect Authentication For Dot Net Nuke
Uk Nuke Facebook Connect Authentication For Dot Net NukeUk Nuke Facebook Connect Authentication For Dot Net Nuke
Uk Nuke Facebook Connect Authentication For Dot Net Nuke
Stuart Lodge
 
AIESEC CMS - User guide
AIESEC CMS - User guideAIESEC CMS - User guide
AIESEC CMS - User guide
Bogdan Rusu
 

Mais procurados (20)

Facebook Connect Presentation 08 10 2008
Facebook Connect Presentation 08 10 2008Facebook Connect Presentation 08 10 2008
Facebook Connect Presentation 08 10 2008
 
Facebook api
Facebook api Facebook api
Facebook api
 
Dbs-Week5-Class-Exercises
Dbs-Week5-Class-ExercisesDbs-Week5-Class-Exercises
Dbs-Week5-Class-Exercises
 
Facebook API in the Real World - Myles Noton - Miniclip
Facebook API in the Real World - Myles Noton - MiniclipFacebook API in the Real World - Myles Noton - Miniclip
Facebook API in the Real World - Myles Noton - Miniclip
 
Facebook Connect Integration
Facebook Connect IntegrationFacebook Connect Integration
Facebook Connect Integration
 
Rapid Development With CakePHP
Rapid Development With CakePHPRapid Development With CakePHP
Rapid Development With CakePHP
 
Facebook Open Graph Tech Requirements
Facebook Open Graph Tech RequirementsFacebook Open Graph Tech Requirements
Facebook Open Graph Tech Requirements
 
The Face Behind Facebook
The Face Behind FacebookThe Face Behind Facebook
The Face Behind Facebook
 
Webinar: PHP and MySQL - Server-side Scripting Language for Web Development
Webinar: PHP and MySQL - Server-side Scripting Language for Web Development  Webinar: PHP and MySQL - Server-side Scripting Language for Web Development
Webinar: PHP and MySQL - Server-side Scripting Language for Web Development
 
Uk Nuke Facebook Connect Authentication For Dot Net Nuke
Uk Nuke Facebook Connect Authentication For Dot Net NukeUk Nuke Facebook Connect Authentication For Dot Net Nuke
Uk Nuke Facebook Connect Authentication For Dot Net Nuke
 
AIESEC CMS - User guide
AIESEC CMS - User guideAIESEC CMS - User guide
AIESEC CMS - User guide
 
Custom Template for Joomla! 3
Custom Template for Joomla! 3Custom Template for Joomla! 3
Custom Template for Joomla! 3
 
Responsive WEB APP using cakePHP
Responsive WEB APP using cakePHPResponsive WEB APP using cakePHP
Responsive WEB APP using cakePHP
 
Workshop : Facebook JavaScript SDK
Workshop : Facebook JavaScript SDKWorkshop : Facebook JavaScript SDK
Workshop : Facebook JavaScript SDK
 
Facebook Platform - Tech
Facebook Platform - TechFacebook Platform - Tech
Facebook Platform - Tech
 
APEX navigation concepts
APEX navigation conceptsAPEX navigation concepts
APEX navigation concepts
 
Introduction to Facebook Javascript SDK (NEW)
Introduction to Facebook Javascript SDK (NEW)Introduction to Facebook Javascript SDK (NEW)
Introduction to Facebook Javascript SDK (NEW)
 
Reff 04 macme-installation-tutorial
Reff 04 macme-installation-tutorialReff 04 macme-installation-tutorial
Reff 04 macme-installation-tutorial
 
UkNuke Facebook Connect Authentication For DotNetNuke 5
UkNuke Facebook Connect Authentication For DotNetNuke 5UkNuke Facebook Connect Authentication For DotNetNuke 5
UkNuke Facebook Connect Authentication For DotNetNuke 5
 
Facebook Apps Development 101 (Java)
Facebook Apps Development 101 (Java)Facebook Apps Development 101 (Java)
Facebook Apps Development 101 (Java)
 

Destaque

Facebook Powerpoint
Facebook PowerpointFacebook Powerpoint
Facebook Powerpoint
myra14
 

Destaque (11)

Facebook Connect
Facebook ConnectFacebook Connect
Facebook Connect
 
Facebook Connect in 3 Hours
Facebook Connect in 3 HoursFacebook Connect in 3 Hours
Facebook Connect in 3 Hours
 
Facebook Connect For Your 
Website
Facebook Connect For Your 
WebsiteFacebook Connect For Your 
Website
Facebook Connect For Your 
Website
 
Facebook Login and Open Graph
Facebook Login and Open GraphFacebook Login and Open Graph
Facebook Login and Open Graph
 
Facebook Connect
Facebook ConnectFacebook Connect
Facebook Connect
 
The Introductory Guide to Social Login
The Introductory Guide to Social LoginThe Introductory Guide to Social Login
The Introductory Guide to Social Login
 
Analysis of 150 Websites Using Facebook Login
Analysis of 150 Websites Using Facebook LoginAnalysis of 150 Websites Using Facebook Login
Analysis of 150 Websites Using Facebook Login
 
Facebook Login & Open Graph Introduction
Facebook Login & Open Graph IntroductionFacebook Login & Open Graph Introduction
Facebook Login & Open Graph Introduction
 
Facebook Connect 5 Things You Wish You Had Known Before You Started
Facebook Connect   5 Things You Wish You Had Known Before You StartedFacebook Connect   5 Things You Wish You Had Known Before You Started
Facebook Connect 5 Things You Wish You Had Known Before You Started
 
Facebook Connect Design Patterns and Metrics
Facebook Connect Design Patterns and MetricsFacebook Connect Design Patterns and Metrics
Facebook Connect Design Patterns and Metrics
 
Facebook Powerpoint
Facebook PowerpointFacebook Powerpoint
Facebook Powerpoint
 

Semelhante a Facebook Connect Tutorial

Facebook API
Facebook APIFacebook API
Facebook API
snipermkd
 
Admin Panel
Admin Panel Admin Panel

Semelhante a Facebook Connect Tutorial (20)

Download PowerPoint Project on social programming for engineering students
Download PowerPoint Project on social programming for engineering studentsDownload PowerPoint Project on social programming for engineering students
Download PowerPoint Project on social programming for engineering students
 
BrownSites: Building and Managing a CMS Infrastructure for Higher Ed
BrownSites: Building and Managing a CMS Infrastructure for Higher EdBrownSites: Building and Managing a CMS Infrastructure for Higher Ed
BrownSites: Building and Managing a CMS Infrastructure for Higher Ed
 
Facebook 3rd Party Api
Facebook 3rd Party ApiFacebook 3rd Party Api
Facebook 3rd Party Api
 
Facebook appsincloud
Facebook appsincloudFacebook appsincloud
Facebook appsincloud
 
Addon Features FileMaker 13
Addon Features FileMaker 13Addon Features FileMaker 13
Addon Features FileMaker 13
 
Fabian Williams SharePoint Saturday New York BCS Deck
Fabian Williams SharePoint Saturday New York BCS DeckFabian Williams SharePoint Saturday New York BCS Deck
Fabian Williams SharePoint Saturday New York BCS Deck
 
Facebook API
Facebook APIFacebook API
Facebook API
 
Leveraging Rails to Build Facebook Apps
Leveraging Rails to Build Facebook AppsLeveraging Rails to Build Facebook Apps
Leveraging Rails to Build Facebook Apps
 
Facebook Coin
Facebook CoinFacebook Coin
Facebook Coin
 
Mule with facebook
Mule with facebookMule with facebook
Mule with facebook
 
Mule with facebook
Mule with facebookMule with facebook
Mule with facebook
 
Building Facebook Apps
Building Facebook AppsBuilding Facebook Apps
Building Facebook Apps
 
Admin Panel
Admin Panel Admin Panel
Admin Panel
 
Build social apps for Facebook
Build social apps for FacebookBuild social apps for Facebook
Build social apps for Facebook
 
Flash Development Guide
Flash Development GuideFlash Development Guide
Flash Development Guide
 
The social media developer
The social media developer The social media developer
The social media developer
 
Facebook Messenger Platform Framework
Facebook Messenger Platform FrameworkFacebook Messenger Platform Framework
Facebook Messenger Platform Framework
 
Developing Joomla Extensions JUG Bangladesh meetup dhaka-2012
Developing Joomla Extensions JUG  Bangladesh meetup dhaka-2012Developing Joomla Extensions JUG  Bangladesh meetup dhaka-2012
Developing Joomla Extensions JUG Bangladesh meetup dhaka-2012
 
Facebook Application Crash Course
Facebook Application Crash CourseFacebook Application Crash Course
Facebook Application Crash Course
 
Getting started with WordPress development
Getting started with WordPress developmentGetting started with WordPress development
Getting started with WordPress development
 

Último

EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 

Último (20)

Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 

Facebook Connect Tutorial

  • 1. Facebook Connect Tutorial Prateek Dayal Muziboo.com Mar 7th, 2010
  • 2. Resources Code: http://github.com/prateekdayal/fb-tutorial This Presentation: http://www.slideshare.net/prateek. dayal/facebook-connect-tutorial FB Connect’s Docs: http://developers.facebook.com/connect.php
  • 3. Setting up a New App Install the ’Developer App’ in Facebook Create a new application (in fact two: one for production and the other for testing) The canvas callback url should point to your website (or your dev machine)
  • 4.
  • 5. SSH Tunnel Setup Problem: You need to access your dev machine over the internet and you don’t have a public IP Solution: Use a ssh tunnel On Linux machines In /etc/ssh/sshd config put GatewayPorts yes Restart the ssh server prateekdayal: # /etc/init.d/ssh restart
  • 6. Starting the Tunnel on localhost Lets assume that you want to forward the local port 3000 to port 3333 on your server (ex: prateekdayal.net) prateek@marvin: /work/talks/acm$ ssh prateek@prateekdayal.net -gNR 3333:localhost:3000 You can now access http://localhost:3000 at http://www.prateekdayal.net:3333
  • 7. Cross Domain Receiver File Problem: Ajax calls from your domain to Facebook.com and passing data from Facebook.com to your domain Solution: Cross Domain Receiver File A technique for passing data between different domains Used for detecting login status, setting fb cookies on your domain etc You can get the file from Facebook’s Dev site You have to place it relative to the root directory of your app <site root>/xd receiver.html
  • 8.
  • 9. Lets build a quick app Objective: Comment on a blogpost with your Facebook ID and post the comment on your news feed
  • 10. Creating the Login page File: public/fb-connect.html Include FB Connect’s Javascript code I have also included prototype.js to make manipulate the DOM more easily Add a form and ’Login with Facebook’ button Add the JS code to render fbml tags 1 1 http://wiki.developers.facebook.com/index.php/Connect/ Authorization_Websites
  • 11.
  • 12. Show User Info File: public/fb-connect-show-info.html Use XFBML tags to show name and profile pic 2 Also provide a Logout button 3 2 http://wiki.developers.facebook.com/index.php/XFBML 3 http://wiki.developers.facebook.com/index.php/Logging_Out_ And_Disconnecting
  • 13.
  • 14. Detecting the Login State File: public/fb-connect-detect-login-state.html Problem: Every time we refresh the page we have to login again Solution: Pass ifUserConnected and ifUserNotConnected options to FB Connect’s init function 4 Remove the separate handlers for login & logout This can be used to automatically login users if they are logged into FB (single sign-on) 4 http: //wiki.developers.facebook.com/index.php/Detecting_Connect_Status
  • 15. Posting to News Feed File: public/fb-connect-feed-story.html We can use FB.Connect.streamPublish to publish to News Feed 5 FB allows pictures, mp3, flash etc to be attached to the feed 5 http://wiki.developers.facebook.com/index.php/Implementing_ Feed_Publishing_from_your_Website_or_Application
  • 16.
  • 17. Server side stuff Problem: You want to let users login with FB and connect existing accounts Solution: Read cookies set by FB (on your domain) to get user id and session id FB User ID can be used to identify the user on next login and connect with your auth system Session ID can be used to make FB API calls (to fetch detailed user info etc) Php, Ruby on Rails and other languages have libraries available to make all this easy
  • 18.
  • 19. Advanced Features Extended session permission Ask for user’s primary email address Friend recommendation and invitation
  • 20. A note on Platform Policies Most of the data (including name) cannot be cached for more than 24 hours If a user de-authorizes your app, you need to delete data received by API (and not direct submission) Many more guidelines 6 6 http://wiki.developers.facebook.com/index.php/Storable_Data
  • 21. Questions? prateek@muziboo.com @prateekdayal http://www.prateekdayal.net http://devblog.muziboo.com