SlideShare une entreprise Scribd logo
1  sur  34
Facebook Apps Dev 101 Damon Widjaja
Facebook Apps Basic Integrate web applications with core Facebook Experience Example: getting user information and posting to wall Benefit? A powerful and cost effective measures for one's product/service to gain exposure (i.e. user engagement, viral effect)
Getting Started Step 1: Registering application Step 2: Setting-up application Step 3: Authorizing application Step 4: Accessing user information Step 5: Interacting with Facebook
Step 1: Registering Application Add Facebook develop apps @ http://www.facebook.com/developers Verify Facebook account (Mobile phone or credit card) Create your application! Get a unique application ID and secret
Here we go source: http://developers.facebook.com/docs/guides/canvas/
Canvas A blank window within Facebook on which to run your application Minimum screen size of only 760 px wide Type of Canvas: iFrame FBML
Tiny screen source: http://developers.facebook.com/docs/guides/canvas/
iFramevs FBML iFrame Benefits: Scalability in the long run (i.e. easy to move to Facebook Connect website) Let you use Javascript, HTML, CSS (Ajax anyone?) Easy to debug FBML Benefits: Easy to access Facebook elements Faster loads Note: FBML might be deprecated
Step 2: Setting-up Application - Canvas Set your canvas name (Very important!) Easy to remember Branding perspective Example: http://www.facebook.com/myapp Set your canvas URL Opens in canvas Example: http://www.myapp.com
Hello world! http://www.myapp.com
Coding time! Development environment assumption Java Struts2 Tomcat mySql Most tutorials and examples on the web is in PHP
Step 3: Authorizing application Is it required? No! BUT it is necessary to create a personalized user experience (i.e. retrieve user email address, post to wall) App creator controls the degree of permissions required during authorization
Tell me how? Call the following URI on your default index page upon load https://www.facebook.com/dialog/oauth?client_id=YOUR_APP_ID&redirect_uri=YOUR_URL Or, append specific scope parameters https://www.facebook.com/dialog/oauth?client_id=YOUR_APP_ID&redirect_uri=YOUR_URL&scope=email,read_stream
Add this application source: http://developers.facebook.com/docs/authentication/
Sample code - Part 1 <script type="text/javascript"> <!-- <% String uri = "http://apps.facebook.com/myapp/login"; String appId = "12345678910"; String perms = "email,user_birthday";   String url = "https://graph.facebook.com/oauth/authorize?scope="+perms+"&client_id=" + appId;  
Sample code - Part 2 if (uri != null) {      try {           uri = java.net.URLEncoder.encode(uri, "UTF-8");      }      catch (java.io.UnsupportedEncodingException e) {      } }   url = url + "&redirect_uri=" + uri; out.println("varurl=quot;"+url+"quot;;"); %>   if(url != null) {    window.open(url, "_parent", ""); } --> </script>
What’s next? Have to know fact! Facebook passes user information in the form of signed_requestparameter to the canvas URL  This signed_requestparameter is a base64url encoded JSON object Huh? Simply saying, signed_requesthas to be decoded to be meaningful!
Super Secret source: http://developers.facebook.com/docs/authentication/signed_request/
Why bother? Within the encoded signed_requestparameter, lies the very important access_token Cool, so what is it for? access_tokenis necessary to gain access to private information granted during authorization And oh, Facebook defines the steps to decode signed_request
Facebook says source: http://developers.facebook.com/docs/authentication/signed_request/
Sample code -  Part 1 String accessToken = null; String signedRequest = request.getParameter("signed_request"); if (signedRequest == null || signedRequest.length() == 0) {      log.error("AUTH ERROR: Facebook signed request is missing");      return"ERROR"; } int count = 0; String payload = null;
Sample code -  Part 2 //Break the code using tokenizer StringTokenizerst = new StringTokenizer(signedRequest, "."); while (st.hasMoreTokens()) {      if(count == 1)      {           payload = st.nextToken();           break;      }      else           st.nextToken();      count++; }
Sample code -  Part 3 //Decode Base64 BASE64Decoder decoder = new BASE64Decoder(); //Replace spe payload = payload.replace("-", "+").replace("_", "/").trim(); //Decode Base64 - payload try {      byte[] decodedPayload = decoder.decodeBuffer(payload);      payload = new String(decodedPayload, "UTF8"); }  catch (IOException e) {      // TODO Auto-generated catch block      log.error("ERROR: Unable to perform Base64 Decode");      return null; }
Sample code -  Part 4 //JSON Decode - payload try {      JSONObjectpayloadObject = new JSONObject(payload);      //Parse JSON data      accessToken = "" + payloadObject.get("oauth_token"); //Retrieve oauth token }  catch (JSONException e)  {      log.error("ERROR: Unable to perform JSON decode"); }
Step 4: Accessing user information The simplicity of Graph API REST standard, returns data in JSON format Try the following http://graph.facebook.com/me http://graph.facebook.com/me/picture
Utilizing access token Most still returns information without access token BUT Data is limited to public information Try the following with access token http://graph.facebook.com/me?access_token= WHILE Some strictly requires access token https://graph.facebook.com/me/friends?access_token=
The Java Way Easy way to execute Graph API request Generic functions supported Get the API from http://code.google.com/p/facebook-java-api/
Sample code FacebookClientfacebookClient = new DefaultFacebookClient(accessToken); JsonObjectfbUserJSON = facebookClient.fetchObject("me", JsonObject.class); String facebookId = fbUserJSON.getString("id"); String firstName = fbUserJSON.getString("first_name");
Step 5: Interacting with Facebook Accessing popular Facebook features Client-side scripting using Javascript SDK Extensive functionalities: From making Graph API calls to opening Popular Dialogs
Popular Dialogs Javascriptfunction to trigger commonly used Facebook dialogs Post to wall Invite friends Permission requested during authentication applies here!
The familiar pop-up! source: http://developers.facebook.com/docs/reference/dialogs/
Sample code - Part 1 <div id="fb-root"></div> <script src="http://connect.facebook.net/en_US/all.js"></script> <script>   FB.init({     appId  : 'YOUR APP ID',     status : true, // check login status     cookie : false, // enable cookies to allow the server to access the session     xfbml  : true  // parse XFBML   });  </script>
Sample code - Part 2 function postToWall() {      FB.ui({             method: 'feed',             name: ‘FacebookDialogs',             link: 'http://my-app.com',             caption: ’Reference Documentation',             description: ’Dialogsprovide simple, consistent interface…',             message: ’Facebook dialogs are soeasy'      }, function(response) {             if (response && response.post_id) {                 alert('Successful!');             } else {                 alert('Uh-oh, something is wrong.');             }      });      return false; }
Congrats! You are now a full-fledge Facebook Apps Developer! Why don’t challenge yourself to do the following: Create a simple Facebook application that incorporates what we have learnt in this session Impress your teacher! Claim it at http://www.gamemaki.com

Contenu connexe

Tendances

Graph API - Facebook Developer Garage Taipei
Graph API - Facebook Developer Garage TaipeiGraph API - Facebook Developer Garage Taipei
Graph API - Facebook Developer Garage TaipeiCardinal Blue Software
 
Introduction to Facebook Graph API and OAuth 2
Introduction to Facebook Graph API and OAuth 2Introduction to Facebook Graph API and OAuth 2
Introduction to Facebook Graph API and OAuth 2Thai Pangsakulyanont
 
Facebook graph api
Facebook graph apiFacebook graph api
Facebook graph apiFagner Moura
 
Web Application Lunacy
Web Application LunacyWeb Application Lunacy
Web Application Lunacyanandvaidya
 
Info2006 Web20 Taly Print
Info2006 Web20 Taly PrintInfo2006 Web20 Taly Print
Info2006 Web20 Taly PrintRam Srivastava
 
Introduction to Facebook Javascript SDK (NEW)
Introduction to Facebook Javascript SDK (NEW)Introduction to Facebook Javascript SDK (NEW)
Introduction to Facebook Javascript SDK (NEW)Colin Su
 
Workshop : Facebook JavaScript SDK
Workshop : Facebook JavaScript SDKWorkshop : Facebook JavaScript SDK
Workshop : Facebook JavaScript SDKDimitar Danailov
 
Pinned Sites in Internet Explorer 9
Pinned Sites in Internet Explorer 9Pinned Sites in Internet Explorer 9
Pinned Sites in Internet Explorer 9Abram John Limpin
 
Done rerea dspamguide2003
Done rerea dspamguide2003Done rerea dspamguide2003
Done rerea dspamguide2003James Arnold
 
Passport js authentication in nodejs how to implement facebook login feature ...
Passport js authentication in nodejs how to implement facebook login feature ...Passport js authentication in nodejs how to implement facebook login feature ...
Passport js authentication in nodejs how to implement facebook login feature ...Katy Slemon
 
Penguin recovery penalty
Penguin recovery penaltyPenguin recovery penalty
Penguin recovery penaltyNilesh Parekh
 
How to create Zoom Meet with Pega
How to create Zoom Meet with PegaHow to create Zoom Meet with Pega
How to create Zoom Meet with PegaSamuelJude1
 
Building Viral Social Experiences
Building Viral Social ExperiencesBuilding Viral Social Experiences
Building Viral Social ExperiencesJonathan LeBlanc
 
Vdomainhosting wordpress-seo-checklist20151016e
Vdomainhosting wordpress-seo-checklist20151016eVdomainhosting wordpress-seo-checklist20151016e
Vdomainhosting wordpress-seo-checklist20151016eGuy Cook
 
Facebook API for Developers : Introducing the Facebook Platform
Facebook API for Developers : Introducing the Facebook PlatformFacebook API for Developers : Introducing the Facebook Platform
Facebook API for Developers : Introducing the Facebook PlatformWildan Maulana
 

Tendances (20)

Graph API - Facebook Developer Garage Taipei
Graph API - Facebook Developer Garage TaipeiGraph API - Facebook Developer Garage Taipei
Graph API - Facebook Developer Garage Taipei
 
Android app development guide for freshers by ace web academy
Android app development guide for freshers  by ace web academyAndroid app development guide for freshers  by ace web academy
Android app development guide for freshers by ace web academy
 
Introduction to Facebook Graph API and OAuth 2
Introduction to Facebook Graph API and OAuth 2Introduction to Facebook Graph API and OAuth 2
Introduction to Facebook Graph API and OAuth 2
 
Facebook graph api
Facebook graph apiFacebook graph api
Facebook graph api
 
Web Application Lunacy
Web Application LunacyWeb Application Lunacy
Web Application Lunacy
 
Info2006 Web20 Taly Print
Info2006 Web20 Taly PrintInfo2006 Web20 Taly Print
Info2006 Web20 Taly Print
 
Pr7 8 clubwear-and-party-wear
Pr7 8 clubwear-and-party-wearPr7 8 clubwear-and-party-wear
Pr7 8 clubwear-and-party-wear
 
Introduction to Facebook Javascript SDK (NEW)
Introduction to Facebook Javascript SDK (NEW)Introduction to Facebook Javascript SDK (NEW)
Introduction to Facebook Javascript SDK (NEW)
 
Workshop : Facebook JavaScript SDK
Workshop : Facebook JavaScript SDKWorkshop : Facebook JavaScript SDK
Workshop : Facebook JavaScript SDK
 
Introduction to HTML5 & CSS3
Introduction to HTML5 & CSS3Introduction to HTML5 & CSS3
Introduction to HTML5 & CSS3
 
Pinned Sites in Internet Explorer 9
Pinned Sites in Internet Explorer 9Pinned Sites in Internet Explorer 9
Pinned Sites in Internet Explorer 9
 
Done rerea dspamguide2003
Done rerea dspamguide2003Done rerea dspamguide2003
Done rerea dspamguide2003
 
Passport js authentication in nodejs how to implement facebook login feature ...
Passport js authentication in nodejs how to implement facebook login feature ...Passport js authentication in nodejs how to implement facebook login feature ...
Passport js authentication in nodejs how to implement facebook login feature ...
 
Penguin recovery penalty
Penguin recovery penaltyPenguin recovery penalty
Penguin recovery penalty
 
How to create Zoom Meet with Pega
How to create Zoom Meet with PegaHow to create Zoom Meet with Pega
How to create Zoom Meet with Pega
 
Facebook API for iOS
Facebook API for iOSFacebook API for iOS
Facebook API for iOS
 
Building Viral Social Experiences
Building Viral Social ExperiencesBuilding Viral Social Experiences
Building Viral Social Experiences
 
Web Spam Techniques
Web Spam TechniquesWeb Spam Techniques
Web Spam Techniques
 
Vdomainhosting wordpress-seo-checklist20151016e
Vdomainhosting wordpress-seo-checklist20151016eVdomainhosting wordpress-seo-checklist20151016e
Vdomainhosting wordpress-seo-checklist20151016e
 
Facebook API for Developers : Introducing the Facebook Platform
Facebook API for Developers : Introducing the Facebook PlatformFacebook API for Developers : Introducing the Facebook Platform
Facebook API for Developers : Introducing the Facebook Platform
 

Similaire à Facebook Apps Dev 101: Integrate Apps with Core Facebook Experience

Facebook developer garage mobile & facebook
Facebook developer garage   mobile & facebookFacebook developer garage   mobile & facebook
Facebook developer garage mobile & facebookFabio Bertone
 
What's New on the Facebook Platform, July 2011
What's New on the Facebook Platform, July 2011What's New on the Facebook Platform, July 2011
What's New on the Facebook Platform, July 2011Iskandar Najmuddin
 
Facebook API
Facebook APIFacebook API
Facebook APIsnipermkd
 
Introduction to Facebook JavaScript & Python SDK
Introduction to Facebook JavaScript & Python SDKIntroduction to Facebook JavaScript & Python SDK
Introduction to Facebook JavaScript & Python SDKColin Su
 
OAuth Introduction
OAuth IntroductionOAuth Introduction
OAuth Introductionh_marvin
 
Facebook Social Plugins
Facebook Social PluginsFacebook Social Plugins
Facebook Social PluginsAizat Faiz
 
What's New on the Facebook Platform, May 2011
What's New on the Facebook Platform, May 2011What's New on the Facebook Platform, May 2011
What's New on the Facebook Platform, May 2011Iskandar Najmuddin
 
Facebook Connect Integration
Facebook Connect IntegrationFacebook Connect Integration
Facebook Connect Integrationmujahidslideshare
 
OpenSocial Intro
OpenSocial IntroOpenSocial Intro
OpenSocial IntroPamela Fox
 
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 Development with Zend Framework
Facebook Development with Zend FrameworkFacebook Development with Zend Framework
Facebook Development with Zend FrameworkBrett Harris
 
Social Apps with the Force.com Toolkit for Facebook
Social Apps with the Force.com Toolkit for FacebookSocial Apps with the Force.com Toolkit for Facebook
Social Apps with the Force.com Toolkit for FacebookSalesforce Developers
 
The Flash Facebook Cookbook - FlashMidlands
The Flash Facebook Cookbook - FlashMidlandsThe Flash Facebook Cookbook - FlashMidlands
The Flash Facebook Cookbook - FlashMidlandsJames Ford
 
Android Quiz App – Test Your IQ.pdf
Android Quiz App – Test Your IQ.pdfAndroid Quiz App – Test Your IQ.pdf
Android Quiz App – Test Your IQ.pdfSudhanshiBakre1
 
Happy facebook developer
Happy facebook developerHappy facebook developer
Happy facebook developerYu-Wei Chuang
 
Getting the Most Out of OpenSocial Gadgets
Getting the Most Out of OpenSocial GadgetsGetting the Most Out of OpenSocial Gadgets
Getting the Most Out of OpenSocial GadgetsAtlassian
 

Similaire à Facebook Apps Dev 101: Integrate Apps with Core Facebook Experience (20)

Facebook + Ruby
Facebook + RubyFacebook + Ruby
Facebook + Ruby
 
Facebook developer garage mobile & facebook
Facebook developer garage   mobile & facebookFacebook developer garage   mobile & facebook
Facebook developer garage mobile & facebook
 
What's New on the Facebook Platform, July 2011
What's New on the Facebook Platform, July 2011What's New on the Facebook Platform, July 2011
What's New on the Facebook Platform, July 2011
 
Facebook Platform
Facebook PlatformFacebook Platform
Facebook Platform
 
Facebook API
Facebook APIFacebook API
Facebook API
 
Introduction to Facebook JavaScript & Python SDK
Introduction to Facebook JavaScript & Python SDKIntroduction to Facebook JavaScript & Python SDK
Introduction to Facebook JavaScript & Python SDK
 
OAuth Introduction
OAuth IntroductionOAuth Introduction
OAuth Introduction
 
Facebook Social Plugins
Facebook Social PluginsFacebook Social Plugins
Facebook Social Plugins
 
What's New on the Facebook Platform, May 2011
What's New on the Facebook Platform, May 2011What's New on the Facebook Platform, May 2011
What's New on the Facebook Platform, May 2011
 
The social media developer
The social media developer The social media developer
The social media developer
 
Facebook Connect Integration
Facebook Connect IntegrationFacebook Connect Integration
Facebook Connect Integration
 
OpenSocial Intro
OpenSocial IntroOpenSocial Intro
OpenSocial Intro
 
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 Development with Zend Framework
Facebook Development with Zend FrameworkFacebook Development with Zend Framework
Facebook Development with Zend Framework
 
Social Apps with the Force.com Toolkit for Facebook
Social Apps with the Force.com Toolkit for FacebookSocial Apps with the Force.com Toolkit for Facebook
Social Apps with the Force.com Toolkit for Facebook
 
The Flash Facebook Cookbook - FlashMidlands
The Flash Facebook Cookbook - FlashMidlandsThe Flash Facebook Cookbook - FlashMidlands
The Flash Facebook Cookbook - FlashMidlands
 
Android Quiz App – Test Your IQ.pdf
Android Quiz App – Test Your IQ.pdfAndroid Quiz App – Test Your IQ.pdf
Android Quiz App – Test Your IQ.pdf
 
Happy facebook developer
Happy facebook developerHappy facebook developer
Happy facebook developer
 
Hi5 Open Social
Hi5   Open SocialHi5   Open Social
Hi5 Open Social
 
Getting the Most Out of OpenSocial Gadgets
Getting the Most Out of OpenSocial GadgetsGetting the Most Out of OpenSocial Gadgets
Getting the Most Out of OpenSocial Gadgets
 

Dernier

How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
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 2024Rafal Los
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
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 interpreternaman860154
 
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.pptxHampshireHUG
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 

Dernier (20)

How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
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
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
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
 
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 Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 

Facebook Apps Dev 101: Integrate Apps with Core Facebook Experience

  • 1. Facebook Apps Dev 101 Damon Widjaja
  • 2. Facebook Apps Basic Integrate web applications with core Facebook Experience Example: getting user information and posting to wall Benefit? A powerful and cost effective measures for one's product/service to gain exposure (i.e. user engagement, viral effect)
  • 3. Getting Started Step 1: Registering application Step 2: Setting-up application Step 3: Authorizing application Step 4: Accessing user information Step 5: Interacting with Facebook
  • 4. Step 1: Registering Application Add Facebook develop apps @ http://www.facebook.com/developers Verify Facebook account (Mobile phone or credit card) Create your application! Get a unique application ID and secret
  • 5. Here we go source: http://developers.facebook.com/docs/guides/canvas/
  • 6. Canvas A blank window within Facebook on which to run your application Minimum screen size of only 760 px wide Type of Canvas: iFrame FBML
  • 7. Tiny screen source: http://developers.facebook.com/docs/guides/canvas/
  • 8. iFramevs FBML iFrame Benefits: Scalability in the long run (i.e. easy to move to Facebook Connect website) Let you use Javascript, HTML, CSS (Ajax anyone?) Easy to debug FBML Benefits: Easy to access Facebook elements Faster loads Note: FBML might be deprecated
  • 9. Step 2: Setting-up Application - Canvas Set your canvas name (Very important!) Easy to remember Branding perspective Example: http://www.facebook.com/myapp Set your canvas URL Opens in canvas Example: http://www.myapp.com
  • 11. Coding time! Development environment assumption Java Struts2 Tomcat mySql Most tutorials and examples on the web is in PHP
  • 12. Step 3: Authorizing application Is it required? No! BUT it is necessary to create a personalized user experience (i.e. retrieve user email address, post to wall) App creator controls the degree of permissions required during authorization
  • 13. Tell me how? Call the following URI on your default index page upon load https://www.facebook.com/dialog/oauth?client_id=YOUR_APP_ID&redirect_uri=YOUR_URL Or, append specific scope parameters https://www.facebook.com/dialog/oauth?client_id=YOUR_APP_ID&redirect_uri=YOUR_URL&scope=email,read_stream
  • 14. Add this application source: http://developers.facebook.com/docs/authentication/
  • 15. Sample code - Part 1 <script type="text/javascript"> <!-- <% String uri = "http://apps.facebook.com/myapp/login"; String appId = "12345678910"; String perms = "email,user_birthday";   String url = "https://graph.facebook.com/oauth/authorize?scope="+perms+"&client_id=" + appId;  
  • 16. Sample code - Part 2 if (uri != null) {      try {           uri = java.net.URLEncoder.encode(uri, "UTF-8");      }      catch (java.io.UnsupportedEncodingException e) {      } }   url = url + "&redirect_uri=" + uri; out.println("varurl=quot;"+url+"quot;;"); %>   if(url != null) {    window.open(url, "_parent", ""); } --> </script>
  • 17. What’s next? Have to know fact! Facebook passes user information in the form of signed_requestparameter to the canvas URL This signed_requestparameter is a base64url encoded JSON object Huh? Simply saying, signed_requesthas to be decoded to be meaningful!
  • 18. Super Secret source: http://developers.facebook.com/docs/authentication/signed_request/
  • 19. Why bother? Within the encoded signed_requestparameter, lies the very important access_token Cool, so what is it for? access_tokenis necessary to gain access to private information granted during authorization And oh, Facebook defines the steps to decode signed_request
  • 20. Facebook says source: http://developers.facebook.com/docs/authentication/signed_request/
  • 21. Sample code - Part 1 String accessToken = null; String signedRequest = request.getParameter("signed_request"); if (signedRequest == null || signedRequest.length() == 0) {      log.error("AUTH ERROR: Facebook signed request is missing");      return"ERROR"; } int count = 0; String payload = null;
  • 22. Sample code - Part 2 //Break the code using tokenizer StringTokenizerst = new StringTokenizer(signedRequest, "."); while (st.hasMoreTokens()) {    if(count == 1)      {           payload = st.nextToken();           break;      }      else           st.nextToken();      count++; }
  • 23. Sample code - Part 3 //Decode Base64 BASE64Decoder decoder = new BASE64Decoder(); //Replace spe payload = payload.replace("-", "+").replace("_", "/").trim(); //Decode Base64 - payload try {      byte[] decodedPayload = decoder.decodeBuffer(payload);      payload = new String(decodedPayload, "UTF8"); }  catch (IOException e) {      // TODO Auto-generated catch block      log.error("ERROR: Unable to perform Base64 Decode");      return null; }
  • 24. Sample code - Part 4 //JSON Decode - payload try {      JSONObjectpayloadObject = new JSONObject(payload);      //Parse JSON data      accessToken = "" + payloadObject.get("oauth_token"); //Retrieve oauth token }  catch (JSONException e)  {      log.error("ERROR: Unable to perform JSON decode"); }
  • 25. Step 4: Accessing user information The simplicity of Graph API REST standard, returns data in JSON format Try the following http://graph.facebook.com/me http://graph.facebook.com/me/picture
  • 26. Utilizing access token Most still returns information without access token BUT Data is limited to public information Try the following with access token http://graph.facebook.com/me?access_token= WHILE Some strictly requires access token https://graph.facebook.com/me/friends?access_token=
  • 27. The Java Way Easy way to execute Graph API request Generic functions supported Get the API from http://code.google.com/p/facebook-java-api/
  • 28. Sample code FacebookClientfacebookClient = new DefaultFacebookClient(accessToken); JsonObjectfbUserJSON = facebookClient.fetchObject("me", JsonObject.class); String facebookId = fbUserJSON.getString("id"); String firstName = fbUserJSON.getString("first_name");
  • 29. Step 5: Interacting with Facebook Accessing popular Facebook features Client-side scripting using Javascript SDK Extensive functionalities: From making Graph API calls to opening Popular Dialogs
  • 30. Popular Dialogs Javascriptfunction to trigger commonly used Facebook dialogs Post to wall Invite friends Permission requested during authentication applies here!
  • 31. The familiar pop-up! source: http://developers.facebook.com/docs/reference/dialogs/
  • 32. Sample code - Part 1 <div id="fb-root"></div> <script src="http://connect.facebook.net/en_US/all.js"></script> <script>   FB.init({     appId  : 'YOUR APP ID',     status : true, // check login status     cookie : false, // enable cookies to allow the server to access the session     xfbml  : true  // parse XFBML   });  </script>
  • 33. Sample code - Part 2 function postToWall() {      FB.ui({             method: 'feed',             name: ‘FacebookDialogs',             link: 'http://my-app.com',             caption: ’Reference Documentation',             description: ’Dialogsprovide simple, consistent interface…',             message: ’Facebook dialogs are soeasy'      }, function(response) {             if (response && response.post_id) {                 alert('Successful!');             } else {                 alert('Uh-oh, something is wrong.');             }      });      return false; }
  • 34. Congrats! You are now a full-fledge Facebook Apps Developer! Why don’t challenge yourself to do the following: Create a simple Facebook application that incorporates what we have learnt in this session Impress your teacher! Claim it at http://www.gamemaki.com

Notes de l'éditeur

  1. Source:http://developers.facebook.com/docs/guides/canvas/http://www.articletrader.com/computers/software/key-benefits-of-facebook-application-development.html
  2. Source:http://www.ccheever.com/blog/?p=10
  3. Source:http://developers.facebook.com/docs/authentication/http://developers.facebook.com/docs/authentication/permissions/
  4. Source:http://developers.facebook.com/docs/authentication/signed_request/
  5. Source:http://developers.facebook.com/docs/authentication/signed_request/
  6. Source:http://developers.facebook.com/docs/authentication/signed_request/
  7. Source:http://developers.facebook.com/docs/authentication/signed_request/
  8. Source:http://developers.facebook.com/docs/authentication/signed_request/
  9. Source:http://developers.facebook.com/docs/reference/api/
  10. Source:http://developers.facebook.com/docs/reference/api/
  11. Source:http://developers.facebook.com/docs/authentication/signed_request/
  12. Source:http://developers.facebook.com/docs/reference/javascript/