SlideShare ist ein Scribd-Unternehmen logo
1 von 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

Weitere ähnliche Inhalte

Was ist angesagt?

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
 

Was ist angesagt? (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
 

Ähnlich wie Facebook Apps Development 101 (Java)

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
 

Ähnlich wie Facebook Apps Development 101 (Java) (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
 

Kürzlich hochgeladen

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 RobisonAnna Loughnan Colquhoun
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusZilliz
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
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 CVKhem
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Zilliz
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
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 Scriptwesley chun
 
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
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
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 DevelopmentsTrustArc
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 

Kürzlich hochgeladen (20)

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
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
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
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
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
 
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
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
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
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 

Facebook Apps Development 101 (Java)

  • 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

Hinweis der Redaktion

  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/