SlideShare a Scribd company logo
1 of 50
Download to read offline
Build Social Apps for Facebook




                             Md Emran Hasan            M A Hossain Tonu
                             Co-founder, CTO          Sr. Software Engineer
                          Right Brain Solution Ltd.       Somewhere in...


Friday, February 24, 12
Overview

                  •       Why work with Facebook?

                  •       Facebook Platform

                  •       General Application Types

                  •       Live app development



Friday, February 24, 12
Friday, February 24, 12
Friday, February 24, 12
Friday, February 24, 12
Why Facebook?




Friday, February 24, 12
Why Facebook?

                  •       A large and active audience

                  •       Global reach (70% non-US)

                  •       Methods for apps to interact with that audience

                  •       Well-defined ways for audience to tell their friends what they like

                  •       Successful apps can make real money


Friday, February 24, 12
Facebook Platform




Friday, February 24, 12
•   Blog: http://www.keenertech.com
•   Facebook: http://www.facebook.com/keenertech
•   Twitter: dkeener2010
•   Email: dkeener@keenertech.com
           dkeener@metrostarsystems.com
The Development
 Landscape
From a PHP Mindset…
• Facebook was designed with PHP in mind
• Integration features were clunky at best
• …including an API (sort of)

But they bought FriendFeed in Aug 2009

• Key tech people were ex-Google
• Knew API’s and scalability issues
…to a Modern API
•   Uses OAuth 2.0 for authentication
•   OpenGraph API - central to Facebook’s plans
•   Relaxation of draconian data storage policies
•   Privacy Permissions on all Data
•   New easy-to-integrate widgets
•   Deprecation of all the old
    technologies


                                   http://www.zazzle.com/paradigm_shift_
                                   shirt-235689301340536532
It’s Been a Rocky Road…
• Facebook still outgrowing the PHP mindset
• No “dev” version of Facebook to test apps
  against upcoming platform changes
• Their REST interfaces may not do REST in
  the way you expect:
 - https://graph.facebook.com/me/friends
 - https://graph.facebook.com/me/home (News Feed)


Just accept it and move on…
Gone, Deprecated, etc.

1. Old REST Web Services

2. FBML and FBJS
 • HTML with extensions
 • JavaScript w/ extensions

3. Facebook Connect
 • Single sign-on for external sites
 • Rebranded as part of OpenGraph API
Facebook Platform

OpenGraph API                           Authentication


• Consistent view of the social graph   • Uses Oauth 2.0
• Represents objects & actions          • Formerly Facebook Connect


                                         OpenGraph
Social Plugins                            Protocol

                                        • Allows external web pages
• The “gateway drug” of the
                                          to be integrated into the
  Facebook Platform
                                          social graph
                                        • Simple meta tags
It’s Still a Moving Target
• Facebook changes often, and with
  little warning
• 3rd party libs always lag behind
  platform changes…
Getting Ready to Develop

① Create a Facebook account
   - You can’t play if you don’t join

① “Install” the Facebook Developer app
    - http://www.facebook.com/developers
① Create a Facebook application
    - Register your app with Facebook

① Record key data elements for later use
   - Application ID (Your OAuth client_id)
   - Application Secret (Your OAuth client_secret)
Some App Variations
• External, Single Sign-On Only
 - Just leverages Facebook’s audience

• External, Shallow Integration (Social Plugins)
 - Quick, easy, limited; no control of branding. Needs JavaScript lib.

• External, Medium Integration (JavaScript)
 - Requires actual programming with the JavaScript lib

• External, Deep Integration (OpenGraph)
 - A deeper user experience, more work

• Facebook Canvas Application
 - Functions within the Facebook context
 - Can integrate with Facebook Business Pages
Example 1: Single Sign-On

        (JavaScript)
Single Sign-On, JavaScript (1)
          Must include the following code:
<div id="fb-root”></div>
<script src="http://connect.facebook.net/en_US/all.js"></script>
<script>
  FB.init({appId: ’123456789012345', status: true, cookie: true, xfbml: true});
  FB.Event.subscribe('auth.sessionChange', function(response) {
  if (response.session) {
     // A user has logged in, and a new cookie has been saved }
  else {
     // The user has logged out, and the cookie has been cleared } });
</script>
Single Sign-On, JavaScript (2)
       <fb:login-button></fb:login-button>



          - Or you can have your own button and call
           FB.login via JavaScript for a login popup…
FB.login(function(response) {
   if (response.session) {
      if (response.perms) {
         // user is logged in and granted some permissions. }
      else {
         // user is logged in, but did not get any permissions }
   } else {
     // user is not logged in
     }
}, {perms:'read_stream,publish_stream,offline_access'});
Facebook Cookie
• Successful logins result in the creation of
  a Facebook cookie
• The cookie is called: fbs_APP_ID
• That cookie can be interrogated by code
  on the server
   - access_token, facebook_id (UID)
• Generally, you create local accounts for
  Facebook users (and record things like
  their name, UID, etc.) after they’ve logged
  in for the 1st time
Example 2: Profile Pics

        (HTML)
Facebook Profile Pics
              • If you know any user’s
                Facebook UID, then you can
                show their profile pic…




https://graph.facebook.com/UID/picture?type=small
Tips and Best Practices
Practical Tips
• Look carefully at performance
  - Control the number of Facebook calls on a page
  - Consider FQL to get data more efficiently
  - FQL has been updated to use OpenGraph
  - Cache data where possible
• If you use the canvas, use the iframe sub-type
  - Better control of the output
  - No need for HTML to be scrubbed (or mangled) by Facebook
• Do periodic regression tests on production code
For Canvas Apps
• “Hybrid Apps” is the way to go
• Limited functionality works within the
  Facebook “canvas”
• For advanced features, users taken to a
  separate site
• Example: PollCast – Users can take polls
  within Facebook, but they create them by
  going to a separate site
Resources
• Facebook Developer Resources
    - http://www.facebook.com/developers
    - http://developer.facebook.com
• AllFacebook.com
    - http://www.allfacebook.com
•   “Developing Facebook Platform Applications with Rails” by
    Michael J. Mangino, Pragmatic Programmers, 2008
    - Seriously outdated, but interesting
Appendix A: App Creation
As a prerequisite for developing
applications for Facebook, you must first
register your app…

This appendix shows the various Facebook
pages involved in the process

NOTE: These 3 screenshots are out-of-
date now, but the basic tasks are still
the same.
What’s the Big Deal?
Initial App Creation




- http://www.facebook.com/developers/createapp.php
- Must fill out a CAPTCHA upon submission
Appendix C: Other Examples
Some more code examples:

• Example 4: Social Plugins (“Like” Button)
• Example 5: Metadata
• Example 6: Canvas App
Example 4: Social Plugins
Social Plugins
• Leverages Facebook’s JavaScript SDK
• Can easily add social plugins to web sites
• Enables rapid “shallow integration”
• Eight type of social plugins available
• Each widget supports customization
  options
• Customization is still limited, though
Available Social Plugins
Adding a Like Button
• “Like” will cause the web page to be
   promoted on the user’s News Feed…and
   will also appear for their friends
• The number of people who “Like” an item
  impacts how often the item will be shown
  on Facebook news feeds
• Facebook will retrieve info about the page
Blog Entry, With “Like” Button
Social Plugin Requirements
Need to have the following code…
   <div id="fb-root"></div>
   <script>
    window.fbAsyncInit = function() {
      FB.init({appId: '106529556064124', status: true, cookie: true,
            xfbml: true});
    };
    (function() {
      var e = document.createElement('script'); e.async = true;
      e.src = document.location.protocol +
       '//connect.facebook.net/en_US/all.js';
      document.getElementById('fb-root').appendChild(e);
    }());
   </script>
Example 5: Metadata
Metadata for Facebook (1)

<html xmlns:og="http://opengraphprotocol.org/schema/"
   xmlns:fb="http://www.facebook.com/2008/fbml">
<head>
<meta property="og:description" content=“Description"/>
 - See http://developers.facebook.com/docs/opengraph#types
<meta property="og:image" content=”/images/ctnt/123/rn.jpg"/>
 - Images should be square and at least 50x50 pixels
Metadata for Facebook (2)

<meta property="og:url" content=”http://.../your_page/"/>
 - Permalink for the article; used by Facebook
<meta property="og:site_name" content=”KeenerTech"/>
 - Official name of your website
<meta property=”fb:app_id" content=” 106529556064124"/>
 - The app ID (or use fb:admins with comma-delimited
   list of Facebook ID’s for the admins)
…
Example 6: Canvas App
Facebook Application
• Entire app functions within the “canvas,”
  i.e.- within the Facebook context
• Two sub-types:
  - Canvas: Deprecated.
  - Iframe: External app functions within an
    iframe
• Many games use iframes with an
  embedded Flash app
• Mostly the same as external apps…now
What Is the Canvas?
The canvas is the area within the Facebook
web site that your application can control.

  - As a “Canvas” app, or…
  - An external app running in an iframe

It looks like this…
This is the Canvas
How Facebook Canvas Apps Work

      1. HTTP               2. HTTP
                                         PHP
                                         App
                           3. API/FQL
                                          Web
                                         Server
      6. HTML   Facebook
                 Server    4. Response



                           5. HTML
Live app development




Friday, February 24, 12

More Related Content

What's hot

Version Control, Writers, and Workflows
Version Control, Writers, and WorkflowsVersion Control, Writers, and Workflows
Version Control, Writers, and Workflowsstc-siliconvalley
 
Continuous Integration Is for Teams: Moving past buzzword driven development
Continuous Integration Is for Teams: Moving past buzzword driven development Continuous Integration Is for Teams: Moving past buzzword driven development
Continuous Integration Is for Teams: Moving past buzzword driven development Pantheon
 
MeteorDay Copenhagen
MeteorDay CopenhagenMeteorDay Copenhagen
MeteorDay CopenhagenLars Buur
 
Why Your Site is Slow: Performance Answers for Your Clients
Why Your Site is Slow: Performance Answers for Your ClientsWhy Your Site is Slow: Performance Answers for Your Clients
Why Your Site is Slow: Performance Answers for Your ClientsPantheon
 
Natural Language UI Testing using Behavior Driven Development with Pavlov and...
Natural Language UI Testing using Behavior Driven Development with Pavlov and...Natural Language UI Testing using Behavior Driven Development with Pavlov and...
Natural Language UI Testing using Behavior Driven Development with Pavlov and...Eric DeLabar
 
Building Enterprise Chat Bots
Building Enterprise Chat BotsBuilding Enterprise Chat Bots
Building Enterprise Chat BotsVasu Jain
 
Hands On With OpenSocial and Embedded Experiences
Hands On With OpenSocial and Embedded ExperiencesHands On With OpenSocial and Embedded Experiences
Hands On With OpenSocial and Embedded ExperiencesRyan Baxter
 
Engage 2019 Software documentation is fun if you have the right tools: Introd...
Engage 2019 Software documentation is fun if you have the right tools: Introd...Engage 2019 Software documentation is fun if you have the right tools: Introd...
Engage 2019 Software documentation is fun if you have the right tools: Introd...AndrewMagerman
 
Am\I\Doing\It\Right? Struktura plików w PHP
Am\I\Doing\It\Right? Struktura plików w PHPAm\I\Doing\It\Right? Struktura plików w PHP
Am\I\Doing\It\Right? Struktura plików w PHPThe Software House
 
Drupal 8 Initiatives
Drupal 8 InitiativesDrupal 8 Initiatives
Drupal 8 InitiativesAngela Byron
 
Opening the mobile web mozilla and firefox os-chit thiri maung
Opening the mobile web   mozilla and firefox os-chit thiri maungOpening the mobile web   mozilla and firefox os-chit thiri maung
Opening the mobile web mozilla and firefox os-chit thiri maungChit Thiri Maung
 
2017 stuysplash-build-tools
2017 stuysplash-build-tools2017 stuysplash-build-tools
2017 stuysplash-build-toolsJeanne Boyarsky
 
Latest Javascript MVC & Front End Frameworks 2017
Latest Javascript MVC & Front End Frameworks 2017Latest Javascript MVC & Front End Frameworks 2017
Latest Javascript MVC & Front End Frameworks 2017AmarInfotech
 
OpenNTF Blast from ILUG 2007
OpenNTF Blast from ILUG 2007OpenNTF Blast from ILUG 2007
OpenNTF Blast from ILUG 2007Kevin Pettitt
 
Getting agile with drupal
Getting agile with drupalGetting agile with drupal
Getting agile with drupalPromet Source
 
Building mobile apps with PhoneGap and Backbone
Building mobile apps with PhoneGap and BackboneBuilding mobile apps with PhoneGap and Backbone
Building mobile apps with PhoneGap and BackboneTroy Miles
 
Debugging tools in web browsers
Debugging tools in web browsersDebugging tools in web browsers
Debugging tools in web browsersSarah Dutkiewicz
 

What's hot (20)

Version Control, Writers, and Workflows
Version Control, Writers, and WorkflowsVersion Control, Writers, and Workflows
Version Control, Writers, and Workflows
 
React - An Overview
React - An OverviewReact - An Overview
React - An Overview
 
Continuous Integration Is for Teams: Moving past buzzword driven development
Continuous Integration Is for Teams: Moving past buzzword driven development Continuous Integration Is for Teams: Moving past buzzword driven development
Continuous Integration Is for Teams: Moving past buzzword driven development
 
MeteorDay Copenhagen
MeteorDay CopenhagenMeteorDay Copenhagen
MeteorDay Copenhagen
 
Why Your Site is Slow: Performance Answers for Your Clients
Why Your Site is Slow: Performance Answers for Your ClientsWhy Your Site is Slow: Performance Answers for Your Clients
Why Your Site is Slow: Performance Answers for Your Clients
 
Natural Language UI Testing using Behavior Driven Development with Pavlov and...
Natural Language UI Testing using Behavior Driven Development with Pavlov and...Natural Language UI Testing using Behavior Driven Development with Pavlov and...
Natural Language UI Testing using Behavior Driven Development with Pavlov and...
 
Building Enterprise Chat Bots
Building Enterprise Chat BotsBuilding Enterprise Chat Bots
Building Enterprise Chat Bots
 
Building a Reddit Clone from the Ground Up
Building a Reddit Clone from the Ground UpBuilding a Reddit Clone from the Ground Up
Building a Reddit Clone from the Ground Up
 
Hands On With OpenSocial and Embedded Experiences
Hands On With OpenSocial and Embedded ExperiencesHands On With OpenSocial and Embedded Experiences
Hands On With OpenSocial and Embedded Experiences
 
Engage 2019 Software documentation is fun if you have the right tools: Introd...
Engage 2019 Software documentation is fun if you have the right tools: Introd...Engage 2019 Software documentation is fun if you have the right tools: Introd...
Engage 2019 Software documentation is fun if you have the right tools: Introd...
 
Am\I\Doing\It\Right? Struktura plików w PHP
Am\I\Doing\It\Right? Struktura plików w PHPAm\I\Doing\It\Right? Struktura plików w PHP
Am\I\Doing\It\Right? Struktura plików w PHP
 
Drupal 8 Initiatives
Drupal 8 InitiativesDrupal 8 Initiatives
Drupal 8 Initiatives
 
Opening the mobile web mozilla and firefox os-chit thiri maung
Opening the mobile web   mozilla and firefox os-chit thiri maungOpening the mobile web   mozilla and firefox os-chit thiri maung
Opening the mobile web mozilla and firefox os-chit thiri maung
 
2017 stuysplash-build-tools
2017 stuysplash-build-tools2017 stuysplash-build-tools
2017 stuysplash-build-tools
 
Latest Javascript MVC & Front End Frameworks 2017
Latest Javascript MVC & Front End Frameworks 2017Latest Javascript MVC & Front End Frameworks 2017
Latest Javascript MVC & Front End Frameworks 2017
 
OpenNTF Blast from ILUG 2007
OpenNTF Blast from ILUG 2007OpenNTF Blast from ILUG 2007
OpenNTF Blast from ILUG 2007
 
Getting agile with drupal
Getting agile with drupalGetting agile with drupal
Getting agile with drupal
 
Building mobile apps with PhoneGap and Backbone
Building mobile apps with PhoneGap and BackboneBuilding mobile apps with PhoneGap and Backbone
Building mobile apps with PhoneGap and Backbone
 
Bp209
Bp209Bp209
Bp209
 
Debugging tools in web browsers
Debugging tools in web browsersDebugging tools in web browsers
Debugging tools in web browsers
 

Viewers also liked

Viewers also liked (8)

Understanding meteor
Understanding meteorUnderstanding meteor
Understanding meteor
 
Secure my ng-app
Secure my ng-appSecure my ng-app
Secure my ng-app
 
JavaScript Wash - Story of UI Development
JavaScript Wash - Story of UI DevelopmentJavaScript Wash - Story of UI Development
JavaScript Wash - Story of UI Development
 
Software Engineering in PHP
Software Engineering in PHPSoftware Engineering in PHP
Software Engineering in PHP
 
Google Maps API
Google Maps APIGoogle Maps API
Google Maps API
 
Google Map API
Google Map APIGoogle Map API
Google Map API
 
Google Maps API
Google Maps APIGoogle Maps API
Google Maps API
 
Before you jump into Angular
Before you jump into AngularBefore you jump into Angular
Before you jump into Angular
 

Similar to Build social apps for Facebook

Building Facebook Apps
Building Facebook AppsBuilding Facebook Apps
Building Facebook AppsDavid Keener
 
Leveraging Rails to Build Facebook Apps
Leveraging Rails to Build Facebook AppsLeveraging Rails to Build Facebook Apps
Leveraging Rails to Build Facebook AppsDavid Keener
 
Interactive with-facebook
Interactive with-facebookInteractive with-facebook
Interactive with-facebookTien Nguyen
 
Php day 2011 - Interactive-with-facebook
Php day 2011 - Interactive-with-facebookPhp day 2011 - Interactive-with-facebook
Php day 2011 - Interactive-with-facebookQuang Anh Le
 
Developers Tools: An overview of Facebook Development
Developers Tools: An overview of Facebook Development Developers Tools: An overview of Facebook Development
Developers Tools: An overview of Facebook Development Clark Davidson
 
Facebook Developer Garage Toronto - Syncapse Presentation
Facebook Developer Garage Toronto - Syncapse PresentationFacebook Developer Garage Toronto - Syncapse Presentation
Facebook Developer Garage Toronto - Syncapse PresentationSyncapse
 
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 studentsSkyingBlogger
 
Facebook Open Stream API - Facebook Developer Garage Dhaka
Facebook Open Stream API - Facebook Developer Garage DhakaFacebook Open Stream API - Facebook Developer Garage Dhaka
Facebook Open Stream API - Facebook Developer Garage DhakaMohammad Emran Hasan
 
OMSPhoenix6-15-2011-workshop four
OMSPhoenix6-15-2011-workshop fourOMSPhoenix6-15-2011-workshop four
OMSPhoenix6-15-2011-workshop fourKathy Jacobs
 
Google App Engine and Social Apps
Google App Engine and Social AppsGoogle App Engine and Social Apps
Google App Engine and Social AppsChris Schalk
 
Facebook app development
Facebook app developmentFacebook app development
Facebook app developmentJohn Boudreaux
 
OpenID vs Facebook Connect vs FriendConnect
OpenID vs Facebook Connect vs FriendConnectOpenID vs Facebook Connect vs FriendConnect
OpenID vs Facebook Connect vs FriendConnectDerek Gallo
 
WordPress Social Meta Optimization | WordCamp Raleigh 2017
WordPress Social Meta Optimization | WordCamp Raleigh 2017WordPress Social Meta Optimization | WordCamp Raleigh 2017
WordPress Social Meta Optimization | WordCamp Raleigh 2017Digital Strategy Works LLC
 
The Proper Tools is Everything: Using and Evaluating Affordable Social Media ...
The Proper Tools is Everything: Using and Evaluating Affordable Social Media ...The Proper Tools is Everything: Using and Evaluating Affordable Social Media ...
The Proper Tools is Everything: Using and Evaluating Affordable Social Media ...Carol Spencer
 
Social networking in drupal
Social networking in drupalSocial networking in drupal
Social networking in drupalTev Tlov
 
Facebook Apps Vs Google Open Social
Facebook Apps Vs Google Open SocialFacebook Apps Vs Google Open Social
Facebook Apps Vs Google Open SocialRachel Vacek
 
Optimizing WordPress sites for SEO and social media by Miriam Schwab
Optimizing WordPress sites for SEO and social media by Miriam SchwabOptimizing WordPress sites for SEO and social media by Miriam Schwab
Optimizing WordPress sites for SEO and social media by Miriam SchwabMiriam Schwab
 
Developing social solutions on Microsoft technologies (SP Social and Yammer)
Developing social solutions on Microsoft technologies (SP Social and Yammer)Developing social solutions on Microsoft technologies (SP Social and Yammer)
Developing social solutions on Microsoft technologies (SP Social and Yammer)SPC Adriatics
 

Similar to Build social apps for Facebook (20)

Building Facebook Apps
Building Facebook AppsBuilding Facebook Apps
Building Facebook Apps
 
Leveraging Rails to Build Facebook Apps
Leveraging Rails to Build Facebook AppsLeveraging Rails to Build Facebook Apps
Leveraging Rails to Build Facebook Apps
 
Interactive with-facebook
Interactive with-facebookInteractive with-facebook
Interactive with-facebook
 
Php day 2011 - Interactive-with-facebook
Php day 2011 - Interactive-with-facebookPhp day 2011 - Interactive-with-facebook
Php day 2011 - Interactive-with-facebook
 
Developers Tools: An overview of Facebook Development
Developers Tools: An overview of Facebook Development Developers Tools: An overview of Facebook Development
Developers Tools: An overview of Facebook Development
 
Facebook Developer Garage Toronto - Syncapse Presentation
Facebook Developer Garage Toronto - Syncapse PresentationFacebook Developer Garage Toronto - Syncapse Presentation
Facebook Developer Garage Toronto - Syncapse Presentation
 
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
 
Facebook Open Stream API - Facebook Developer Garage Dhaka
Facebook Open Stream API - Facebook Developer Garage DhakaFacebook Open Stream API - Facebook Developer Garage Dhaka
Facebook Open Stream API - Facebook Developer Garage Dhaka
 
OMSPhoenix6-15-2011-workshop four
OMSPhoenix6-15-2011-workshop fourOMSPhoenix6-15-2011-workshop four
OMSPhoenix6-15-2011-workshop four
 
Google App Engine and Social Apps
Google App Engine and Social AppsGoogle App Engine and Social Apps
Google App Engine and Social Apps
 
Facebook app development
Facebook app developmentFacebook app development
Facebook app development
 
OpenID vs Facebook Connect vs FriendConnect
OpenID vs Facebook Connect vs FriendConnectOpenID vs Facebook Connect vs FriendConnect
OpenID vs Facebook Connect vs FriendConnect
 
The social media developer
The social media developer The social media developer
The social media developer
 
Facebook Connect
Facebook ConnectFacebook Connect
Facebook Connect
 
WordPress Social Meta Optimization | WordCamp Raleigh 2017
WordPress Social Meta Optimization | WordCamp Raleigh 2017WordPress Social Meta Optimization | WordCamp Raleigh 2017
WordPress Social Meta Optimization | WordCamp Raleigh 2017
 
The Proper Tools is Everything: Using and Evaluating Affordable Social Media ...
The Proper Tools is Everything: Using and Evaluating Affordable Social Media ...The Proper Tools is Everything: Using and Evaluating Affordable Social Media ...
The Proper Tools is Everything: Using and Evaluating Affordable Social Media ...
 
Social networking in drupal
Social networking in drupalSocial networking in drupal
Social networking in drupal
 
Facebook Apps Vs Google Open Social
Facebook Apps Vs Google Open SocialFacebook Apps Vs Google Open Social
Facebook Apps Vs Google Open Social
 
Optimizing WordPress sites for SEO and social media by Miriam Schwab
Optimizing WordPress sites for SEO and social media by Miriam SchwabOptimizing WordPress sites for SEO and social media by Miriam Schwab
Optimizing WordPress sites for SEO and social media by Miriam Schwab
 
Developing social solutions on Microsoft technologies (SP Social and Yammer)
Developing social solutions on Microsoft technologies (SP Social and Yammer)Developing social solutions on Microsoft technologies (SP Social and Yammer)
Developing social solutions on Microsoft technologies (SP Social and Yammer)
 

Recently uploaded

Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 

Recently uploaded (20)

Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 

Build social apps for Facebook

  • 1. Build Social Apps for Facebook Md Emran Hasan M A Hossain Tonu Co-founder, CTO Sr. Software Engineer Right Brain Solution Ltd. Somewhere in... Friday, February 24, 12
  • 2. Overview • Why work with Facebook? • Facebook Platform • General Application Types • Live app development Friday, February 24, 12
  • 7. Why Facebook? • A large and active audience • Global reach (70% non-US) • Methods for apps to interact with that audience • Well-defined ways for audience to tell their friends what they like • Successful apps can make real money Friday, February 24, 12
  • 9. Blog: http://www.keenertech.com • Facebook: http://www.facebook.com/keenertech • Twitter: dkeener2010 • Email: dkeener@keenertech.com dkeener@metrostarsystems.com
  • 11.
  • 12.
  • 13. From a PHP Mindset… • Facebook was designed with PHP in mind • Integration features were clunky at best • …including an API (sort of) But they bought FriendFeed in Aug 2009 • Key tech people were ex-Google • Knew API’s and scalability issues
  • 14. …to a Modern API • Uses OAuth 2.0 for authentication • OpenGraph API - central to Facebook’s plans • Relaxation of draconian data storage policies • Privacy Permissions on all Data • New easy-to-integrate widgets • Deprecation of all the old technologies http://www.zazzle.com/paradigm_shift_ shirt-235689301340536532
  • 15. It’s Been a Rocky Road… • Facebook still outgrowing the PHP mindset • No “dev” version of Facebook to test apps against upcoming platform changes • Their REST interfaces may not do REST in the way you expect: - https://graph.facebook.com/me/friends - https://graph.facebook.com/me/home (News Feed) Just accept it and move on…
  • 16. Gone, Deprecated, etc. 1. Old REST Web Services 2. FBML and FBJS • HTML with extensions • JavaScript w/ extensions 3. Facebook Connect • Single sign-on for external sites • Rebranded as part of OpenGraph API
  • 17. Facebook Platform OpenGraph API Authentication • Consistent view of the social graph • Uses Oauth 2.0 • Represents objects & actions • Formerly Facebook Connect OpenGraph Social Plugins Protocol • Allows external web pages • The “gateway drug” of the to be integrated into the Facebook Platform social graph • Simple meta tags
  • 18. It’s Still a Moving Target • Facebook changes often, and with little warning • 3rd party libs always lag behind platform changes…
  • 19. Getting Ready to Develop ① Create a Facebook account - You can’t play if you don’t join ① “Install” the Facebook Developer app - http://www.facebook.com/developers ① Create a Facebook application - Register your app with Facebook ① Record key data elements for later use - Application ID (Your OAuth client_id) - Application Secret (Your OAuth client_secret)
  • 20. Some App Variations • External, Single Sign-On Only - Just leverages Facebook’s audience • External, Shallow Integration (Social Plugins) - Quick, easy, limited; no control of branding. Needs JavaScript lib. • External, Medium Integration (JavaScript) - Requires actual programming with the JavaScript lib • External, Deep Integration (OpenGraph) - A deeper user experience, more work • Facebook Canvas Application - Functions within the Facebook context - Can integrate with Facebook Business Pages
  • 21. Example 1: Single Sign-On (JavaScript)
  • 22. Single Sign-On, JavaScript (1) Must include the following code: <div id="fb-root”></div> <script src="http://connect.facebook.net/en_US/all.js"></script> <script> FB.init({appId: ’123456789012345', status: true, cookie: true, xfbml: true}); FB.Event.subscribe('auth.sessionChange', function(response) { if (response.session) { // A user has logged in, and a new cookie has been saved } else { // The user has logged out, and the cookie has been cleared } }); </script>
  • 23. Single Sign-On, JavaScript (2) <fb:login-button></fb:login-button> - Or you can have your own button and call FB.login via JavaScript for a login popup… FB.login(function(response) { if (response.session) { if (response.perms) { // user is logged in and granted some permissions. } else { // user is logged in, but did not get any permissions } } else { // user is not logged in } }, {perms:'read_stream,publish_stream,offline_access'});
  • 24. Facebook Cookie • Successful logins result in the creation of a Facebook cookie • The cookie is called: fbs_APP_ID • That cookie can be interrogated by code on the server - access_token, facebook_id (UID) • Generally, you create local accounts for Facebook users (and record things like their name, UID, etc.) after they’ve logged in for the 1st time
  • 25. Example 2: Profile Pics (HTML)
  • 26. Facebook Profile Pics • If you know any user’s Facebook UID, then you can show their profile pic… https://graph.facebook.com/UID/picture?type=small
  • 27. Tips and Best Practices
  • 28. Practical Tips • Look carefully at performance - Control the number of Facebook calls on a page - Consider FQL to get data more efficiently - FQL has been updated to use OpenGraph - Cache data where possible • If you use the canvas, use the iframe sub-type - Better control of the output - No need for HTML to be scrubbed (or mangled) by Facebook • Do periodic regression tests on production code
  • 29. For Canvas Apps • “Hybrid Apps” is the way to go • Limited functionality works within the Facebook “canvas” • For advanced features, users taken to a separate site • Example: PollCast – Users can take polls within Facebook, but they create them by going to a separate site
  • 30. Resources • Facebook Developer Resources - http://www.facebook.com/developers - http://developer.facebook.com • AllFacebook.com - http://www.allfacebook.com • “Developing Facebook Platform Applications with Rails” by Michael J. Mangino, Pragmatic Programmers, 2008 - Seriously outdated, but interesting
  • 31. Appendix A: App Creation As a prerequisite for developing applications for Facebook, you must first register your app… This appendix shows the various Facebook pages involved in the process NOTE: These 3 screenshots are out-of- date now, but the basic tasks are still the same.
  • 33. Initial App Creation - http://www.facebook.com/developers/createapp.php - Must fill out a CAPTCHA upon submission
  • 34.
  • 35. Appendix C: Other Examples Some more code examples: • Example 4: Social Plugins (“Like” Button) • Example 5: Metadata • Example 6: Canvas App
  • 36. Example 4: Social Plugins
  • 37. Social Plugins • Leverages Facebook’s JavaScript SDK • Can easily add social plugins to web sites • Enables rapid “shallow integration” • Eight type of social plugins available • Each widget supports customization options • Customization is still limited, though
  • 39. Adding a Like Button • “Like” will cause the web page to be promoted on the user’s News Feed…and will also appear for their friends • The number of people who “Like” an item impacts how often the item will be shown on Facebook news feeds • Facebook will retrieve info about the page
  • 40. Blog Entry, With “Like” Button
  • 41. Social Plugin Requirements Need to have the following code… <div id="fb-root"></div> <script> window.fbAsyncInit = function() { FB.init({appId: '106529556064124', status: true, cookie: true, xfbml: true}); }; (function() { var e = document.createElement('script'); e.async = true; e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js'; document.getElementById('fb-root').appendChild(e); }()); </script>
  • 43. Metadata for Facebook (1) <html xmlns:og="http://opengraphprotocol.org/schema/" xmlns:fb="http://www.facebook.com/2008/fbml"> <head> <meta property="og:description" content=“Description"/> - See http://developers.facebook.com/docs/opengraph#types <meta property="og:image" content=”/images/ctnt/123/rn.jpg"/> - Images should be square and at least 50x50 pixels
  • 44. Metadata for Facebook (2) <meta property="og:url" content=”http://.../your_page/"/> - Permalink for the article; used by Facebook <meta property="og:site_name" content=”KeenerTech"/> - Official name of your website <meta property=”fb:app_id" content=” 106529556064124"/> - The app ID (or use fb:admins with comma-delimited list of Facebook ID’s for the admins) …
  • 46. Facebook Application • Entire app functions within the “canvas,” i.e.- within the Facebook context • Two sub-types: - Canvas: Deprecated. - Iframe: External app functions within an iframe • Many games use iframes with an embedded Flash app • Mostly the same as external apps…now
  • 47. What Is the Canvas? The canvas is the area within the Facebook web site that your application can control. - As a “Canvas” app, or… - An external app running in an iframe It looks like this…
  • 48. This is the Canvas
  • 49. How Facebook Canvas Apps Work 1. HTTP 2. HTTP PHP App 3. API/FQL Web Server 6. HTML Facebook Server 4. Response 5. HTML
  • 50. Live app development Friday, February 24, 12