Facebook Apps Dev 101 Damon Widjaja 商大师

Slides:



Advertisements
Similar presentations
Authentication Simon Cross Partner Engineer facebook.com/sicross An Overview.
Advertisements

OAuth 2.0 By “PJ” (JP on meetup.com) iOS and PHP developer, and occasional lawyer Contact me via:
Facebook Applications Teppo Räisänen. Facebook Applications Facebook provides many Software Development Kits (SDK’s) – PHP SDK – iOS SDK – Android SDK.
Electrical and Computer Engineering Vitaly Gordievsky Alex Trefonas Scott Richard Matt Beckford Final Project Review.
Hannes Tschofenig MIT CFP Privacy & Security Working Group Feb. 2 nd 2011.
IS 360 Course Introduction. Slide 2 What you will Learn (1) The role of Web servers and clients How to create HTML, XHTML, and HTML 5 pages suitable for.
Basic concept Technologies we have used The Design Problems, challenges & solutions Educational Gain.
With jQuery and AJAX Doncho Minkov Telerik Corporation Technical Trainer.
Hints for HW#8. HW#6 Architecture Result of Query GOOG Browser with web page PHP Script client Apache web server finance.yahoo.com Send query with arguments.
Web Proxy Server. Proxy Server Introduction Returns status and error messages. Handles http CGI requests. –For more information about CGI please refer.
CAEL 5012 Rich Internet Applications. What you need For this part of the course you will need access to a server with PHP and MYSQL which will be supplied.
Chris Pinski.  History  What is Ajax  Who uses Ajax  Underlying Technologies  SE Aspect  Common Problems  Conclusion.
Social Media Apps Programming Min-Yuh Day, Ph.D. Assistant Professor Department of Information Management Tamkang University
BUILDING A FACEBOOK APP. STEP 1 Create a Developers License. Make sure to take note/record the app id/key.
JavaScript & jQuery the missing manual Chapter 11
Web Programming: Client/Server Applications Server sends the web pages to the client. –built into Visual Studio for development purposes Client displays.
Social Media Apps Programming Min-Yuh Day, Ph.D. Assistant Professor Department of Information Management Tamkang University
Tutorial 10 Programming with JavaScript
Sponsors Gold Silver Bronze Custom REST services and jQuery AJAX Building your own custom REST services and consuming them with jQuery AJAX.
Sponsors Gold Silver Bronze Custom REST services and jQuery AJAX Building your own custom REST services and consuming them with jQuery AJAX.
Lecture 9: AJAX, Javascript review..  AJAX  Synchronous vs. asynchronous browsing.  Refreshing only “part of a page” from a URL.  Frameworks: Prototype,
CS 4720 Dynamic Web Applications CS 4720 – Web & Mobile Systems.
 Facebook Integration on iOS Phan Thanh Phat Huynh Thanh Van.
Facebook API Kelly Orser. Client Libraries Client libraries will simplify the calls to the platform by reducing the amount of code you have to write.
Facebook is a social utility that connects you with the people around you. Use Facebook to…  Keep up with friends and family  Share photos and videos.
Social Media Apps Programming Min-Yuh Day, Ph.D. Assistant Professor Department of Information Management Tamkang University
Esri UC 2014 | Demo Theater | Using ArcGIS Online App Logins in Node.js James Tedrick.
UNDERSTANDING YOUR OPTIONS FOR CLIENT-SIDE DEVELOPMENT IN OFFICE 365 Mark Rackley
JavaScript Introduction and Background. 2 Web languages Three formal languages HTML JavaScript CSS Three different tasks Document description Client-side.
Explicating SDKs: Uncovering Assumptions Underlying Secure Authentication and Authorization Rui Wang 1 *, Yuchen Zhou 2 * †, (*Lead authors, † Speaker)
AJAX CS456 Fall Examples Where is AJAX used? Why do we care?
Virtual techdays INDIA │ November 2010 Integrating Social Networks with ASP.NET Krishna Chaitanya T │ Future Web Research Lab, SETLabs, Infosys WE.
SlideSet #20: Input Validation and Cross-site Scripting Attacks (XSS) SY306 Web and Databases for Cyber Operations.
(Part 2). From Part 1 We …  Signed up to be facebook developers Verified our facebook account. Added facebook developer app.  Setup a Heroku facebook.
National College of Science & Information Technology.
Developers Introduction to the Power BI Platform.
PHP using MySQL Database for Web Development (part II)
Jim Fawcett CSE686 – Internet Programming Spring 2014
Tonga Institute of Higher Education IT 141: Information Systems
Web Technologies Computing Science Thompson Rivers University
“Under the hood”: Angry Birds Maze
Jim Fawcett CSE686 – Internet Programming Spring 2012
Tutorial 10 Programming with JavaScript
Data Virtualization Tutorial… CORS and CIS
Cosc 5/4730 REST services.
Data Virtualization Tutorial… OAuth Example using Google Sheets
PHP –MySQL Interview Question And Answer.
Sessions and cookies (part 2)
All about social networking
Creating Novell Portal Services Gadgets: An Architectural Overview
APIs (and their Relatives) Can Expand and Unify Library Services
PHP / MySQL Introduction
Customizing your device experience with assigned access
Testing REST IPA using POSTMAN
Web Systems Development (CSC-215)
IS 360 Course Introduction
Tonga Institute of Higher Education IT 141: Information Systems
Web Systems Development (CSC-215)
PHP.
The 1st International Open Science Conference
Tonga Institute of Higher Education IT 141: Information Systems
ARCHITECTURE OVERVIEW
Intro to PHP.
Token-based Authentication
RESTful Web Services.
PHP an introduction.
Web Technologies Computing Science Thompson Rivers University
D Guidance 26-Jun: Would like to see a refresh of this title slide
Development of Twitter Applications Part 3. OAuth
Web Application Development Using PHP
Presentation transcript:

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)

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

Step 1: Registering Application Add Facebook develop Verify Facebook account (Mobile phone or credit card) Create your application! Get a unique application ID and secret

Here we go source:

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:

iFrame vs 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: Set your canvas URL Opens in canvas Example:

Hello world!

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 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 OUR_APP_ID&redirect_uri=YOUR_URL Or, append specific scope parameters OUR_APP_ID&redirect_uri=YOUR_URL&scope=emai l,read_stream

14 Add this application source:

Sample code - Part 1 <!-- <% String uri = " String appId = " "; String perms = " ,user_birthday"; String url = " rms+"&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("var url=\""+url+"\";"); %> if(url != null) { window.open(url, "_parent", ""); } -->

17 What’s next? Have to know fact! Facebook passes user information in the form of signed_request parameter to the canvas URL This signed_request parameter is a base64url encoded JSON object Huh? Simply saying, signed_request has to be decoded to be meaningful!

18 Super Secret source:

Why bother? Within the encoded signed_request parameter, lies the very important access_token Cool, so what is it for? access_token is necessary to gain access to private information granted during authorization And oh, Facebook defines the steps to decode signed_request

Facebook says source:

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 StringTokenizer st = 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 { JSONObject payloadObject = 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

26 Utilizing access token Most still returns information without access token BUT Data is limited to public information Try the following with access token WHILE Some strictly requires access token

27 The Java Way Easy way to execute Graph API request Generic functions supported Get the API from

Sample code FacebookClient facebookClient = new DefaultFacebookClient(accessToken); JsonObject fbUserJSON = 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 Javascript function to trigger commonly used Facebook dialogs Post to wall Invite friends Permission requested during authentication applies here!

The familiar pop-up! source:

Sample code - Part 1 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 });

Sample code - Part 2 function postToWall() { FB.ui({ method: 'feed', name: ‘Facebook Dialogs', link: ' caption: ’Reference Documentation', description: ’Dialogs provide simple, consistent interface…', message: ’Facebook dialogs are so easy' }, 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