Facebook Applications Teppo Risnen Facebook Applications Facebook provides
Facebook Applications Teppo Räisänen
Facebook Applications • Facebook provides many Software Development Kits (SDK’s) – PHP SDK – i. OS SDK – Android SDK – Java. Script SDK
Facebook Applications • Because school server does not support the newest PHP SDK we will use Java. Script SDK – Java. Script SDK provides a rich set of functionality for accessing Facebook’s API – Allow us to render XFBML versions of Social plugins – Invite friends, post to wall etc.
Facebook Applications • You load the SDK using the standard <script> element and calling FB. init -function – You must specify a <div> element named fb-root within the document as well.
Facebook Applications • <div id="fb-root"></div> <script src="http: //connect. facebook. net/en_US/all. js"> </script> <script> FB. init({ app. Id : 'YOUR APP ID', status : true, // check login status cookie : true, // enable cookies xfbml : true, // parse XFBML channel. URL : 'http: //WWW. DOMAIN. COM/channel. html', oauth : true // enable OAuth 2. 0 }); </script>
Facebook Applications • Channel. html must contain only one line: <script src="http: //connect. facebook. net/en_US/all. js"></script> • This helps with few known bugs
Facebook Applications • The first step is figuring out how you identify who the current user is, and how to make API calls on their behalf – FB. login() -- login and/or request extended permissions – FB. logout() -- logout (only if the user is connected with your application) – FB. get. Login. Status() -- get current login status from facebook. com – FB. get. Session() -- synchronous accessor for the current session • See https: //developers. facebook. com/docs/reference/javascrip t/ for more info
Facebook Applications • API calls can be made with FB. api –function: FB. api('/me', function(response) { alert(response. name); }); • Makes a popup window displaying user’s name • See http: //developers. facebook. com/docs/reference/jav ascript/FB. api/ for more info
Facebook Applications • API calls can be made with FB. api –function: FB. api('/me', function(response) { alert(response. name); }); • Makes a popup window displaying user’s name • See http: //developers. facebook. com/docs/reference/jav ascript/FB. api/ for more info
Facebook Applications • See https: //apps. facebook. com/fbamdemoapp/ • Source code • http: //www. students. oamk. fi/~teraisan/fbam/demoap p. zip
- Slides: 10