H APPY  F ACEBOOK  D EVELOPER
O UTLINE Self-Introduction  History and Trends The Resource we need to know What Facebook Provide Now What languages We use in this offering  Add Facebook to my site Apps on Facebook.com Mobile apps
SELF-INTRODUCTION Eric Chuang / ddsakura
INTRODUCTION Facebook
H ISTORY   AND  S TATICS 2004/2    Mark Zuckerberg launch Facebook
H ISTORY   AND  S TATICS 2007/10  Facebook reaches over  50 million active users 2004/2    Mark Zuckerberg launch Facebook
H ISTORY   AND  S TATICS 2008/8    Facebook reaches over 100 million active users 2007/10  Facebook reaches over  50 million active users 2004/2    Mark Zuckerberg launch Facebook
H ISTORY   AND  S TATICS 2009/9    Facebook reaches over 300 million active users 2009/2    Facebook reaches over 200 million active users 2008/8    Facebook reaches over 100 million active users 2007/10  Facebook reaches over  50 million active users 2004/2    Mark Zuckerberg launch Facebook
H ISTORY   AND  S TATICS 2010/2    Facebook reaches over 400 million active users 2009/12  Facebook reaches over 350 million active users 2009/9    Facebook reaches over 300 million active users 2009/2    Facebook reaches over 200 million active users 2008/8    Facebook reaches over 100 million active users 2007/10  Facebook reaches over  50 million active users 2004/2    Mark Zuckerberg launch Facebook
H ISTORY   AND  S TATICS 全球有 四億多 會員,台灣則有 650 萬
H ISTORY   AND  S TATICS 有 50% 的會員,每天會造訪 Facebook
H ISTORY   AND  S TATICS 所有會員每個月花超過 5000 億 分鐘在 Facebook 上
H ISTORY   AND  S TATICS Facebook 上有 1.6 億 個物件與會員進行互動
H ISTORY   AND  S TATICS Facebook 有超過 70 種語系 版本
H ISTORY   AND  S TATICS 有約 70% 的 Facebook 會員來自美國以外
H ISTORY   AND  S TATICS 有超過 100 萬 個網站和 Facebook 整合
H ISTORY   AND  S TATICS Facebook 有超過 55 萬 個 Apps
H ISTORY   AND  S TATICS 每月有 70% 的會員用使用 Apps
H ISTORY   AND  S TATICS 有超過 100 萬 的會員透過手機連到 Facebook
H ISTORY   AND  S TATICS
Sony Pictures has released the first trailer for the upcoming movie, “The Social Network”, which is loosely based (sensationalized) on the history of Facebook http://www.thesocialnetwork-movie.com/ http://www.youtube.com/watch?v=mWoUgftTj3Y
The Interface of Facebook
The Interface of Facebook
The Interface of Facebook
The Interface of Facebook
THE RESOURCE WE NEED TO KNOW Facebook
T HE  R ESOURCE  W E   NEED   TO   KNOW Facebook Developer Wiki  http://wiki.developers.facebook.com/index.php/Main_Page Facebook developers Site  http://developers.facebook.com/  Developer Blog http://developers.facebook.com/blog/  All Facebook http://www.allfacebook.com/ Inside Facebook http://www.insidefacebook.com/ http://www.facebook.com/developers/ Tools Firefox Firebug http://developers.facebook.com/tools/
W HAT   LANGUAGES  W E   USE   IN   THIS   OFFERING   Javascript PHP And we will also take a look at Facebook iPhone API
W HAT   LANGUAGES  W E   USE   IN   THIS   OFFERING   But We Don’t discuss the skill for JavaScript, PHP, Objective-C, etc.
Big Event f8 developer conference on April 21, 2010.
W HAT  F ACEBOOK  P ROVIDES  N OW Facebook for Website Apps on Facebook.com Mobile Apps
A DD  F ACEBOOK   TO   MY   WEBSITE Facebook
A DD  F ACEBOOK   TO   MY   WEBSITE Social Plugins Single Sign-on Graph API Open Graph Protocol Analytics Platform showcase
SOCIAL PLUGINS Facebook
S OCIAL  P LUGINS
S OCIAL  P LUGINS The easiest way to get started with Facebook Platform.  We Can Use iframe or XFBML method   Sample Code (iframe) <iframe src=&quot;http://www.facebook.com/widgets/like.php?href= http://example.com &quot; scrolling=&quot;no&quot; frameborder=&quot;0&quot; style=&quot;border:none; width:450px; height:80px&quot;></iframe>
Demo
SINGLE SIGN-ON Facebook
Single Sign-on Oauth 2.0 protocol http://tools.ietf.org/html/draft-ietf-oauth-v2-08 http://hueniverse.com/2010/05/introducing-oauth-2-0/  We Can get basically: All general information: like name, profile picture, gender and network. We can get more Ask extended Permisson http://developers.facebook.com/docs/authentication/permissions JavaScript SDK  is a simple way <div id=&quot;fb-root&quot;></div>  <script src=&quot;http://connect.facebook.net/en_US/all.js&quot;></script>  <script> FB.init({appId: ' your app id ', 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 How to and Flow Register Our App http://tools.ietf.org/html/draft-ietf-oauth-v2-08 http://hueniverse.com/2010/05/introducing-oauth-2-0/  Redirect the user to https://graph.facebook.com/oauth/authorize with client_id After the user authorizes your application, Facebook redirects the user to the callback URL you specified with the access token in the URL fragment: Use the access token returned by the request above to fetch data from the Graph API on behalf of the user.
Extended Permission Register Our App http://tools.ietf.org/html/draft-ietf-oauth-v2-08 http://hueniverse.com/2010/05/introducing-oauth-2-0/  http://developers.facebook.com/docs/authentication/permissions
GRAPH API Facebook
Register Apps http://www.facebook.com/?ref=logo#!/developers/apps.php
Graph API (1) - get data https://graph.facebook.com/ID
Graph API (2) - get data https://graph.facebook.com/ID/CONNECTION_TYPE
Graph API (3) - selection, Introspection https://graph.facebook.com/ID?fields=A,B,C... https://graph.facebook.com/?ids=XXX,YYY
Graph API (4) POST We can publish to the Facebook graph by issuing HTTP POST requests to the appropriate connection URLs
Graph API (5) Delete We can delete objects in the graph by issuing HTTP DELETE requests to the object DELETE https://graph.facebook.com/ID?access_token=... HTTP/1.1 OR https://graph.facebook.com/COMMENT_ID?method=delete
Graph API (6) Search We can search over all public objects https://graph.facebook.com/search?q=QUERY&type=OBJECT_TYPE For Example All public posts: https://graph.facebook.com/search?q=watermelon&type=post People: https://graph.facebook.com/search?q=mark&type=user Pages: https://graph.facebook.com/search?q=platform&type=page Events: https://graph.facebook.com/search?q=conference&type=event Groups: https://graph.facebook.com/search?q=programming&type=group
Graph API (7) Tool Graph API reference http://developers.facebook.com/docs/reference/api/
Graph API (8) Tools CURL Javascript
OPEN GRAPH PROTOCOL Facebook
Introduction
Introduction – from insidefacebook.com
Getting Start
http://developers.facebook.com/tools/lint/ Tool: URL Linter
Administering our page
Location Meta Data
Analytics http://www.facebook.com/insights/
ShowCase
JAVASCRIPT SDK Facebook
JavaScript SDK(1) The JavaScript SDK enables you to access all of the features of the Graph API via JavaScript The JavaScript SDK is also necessary to use the XFBML  Must register your application. The SDK is open source and is available on http://github.com/facebook/connect-js
JavaScript SDK(2) Core Methods Event Handling XFBML Methods Data Access Utilities Canvas Methods
JavaScript SDK(3) – Core Methods FB.api Make a API call <script> FB.api('/me', function(response) {   console.log(response); }); </script>
JavaScript SDK(4) – Core Methods FB.getLoginStatus Find out the current status from the server, and get a session if the user is connected. <script> FB.getLoginStatus(function(response) {   if (response.session) {     alert('Coneected');   } else {     alert('No Coneected');   } }); </script>
JavaScript SDK(5) – Core Methods FB.login Login/Authorize/Permissions. <button id=&quot;fb-login&quot;>Login</button> <script> document.getElementById('fb-login').onclick = function() {   FB.login(function(response) {     Log.info('FB.login callback', response);     if (response.session) {       Log.info('User is logged in');     } else {       Log.info('User is logged out');     }   }); }; </script>
JavaScript SDK(6) – Core Methods FB.logout Logout the user in the background. <button id=&quot;fb-logout&quot;>Logout</button> <script> document.getElementById('fb-logout').onclick = function() {   FB.logout(function(response) {     alert('logout!');   // user is now logged out   }); }; </script>
JavaScript SDK(7) – Core Methods FB.ui Method for triggering UI interaction with Facebook as IFrame dialogs or popups, like publishing to the stream, sharing links. <script>  var share = {    method: 'stream.share',    u: 'http://www.cht.com.tw/'  };  FB.ui(share, function(response) { console.log(response); }); </script>
JavaScript SDK(8) – Event Handling FB.Event.subscribe Subscribe to a given event name, invoking your callback function whenever the event is fired. <script>  FB.Event.subscribe('auth.sessionChange', function(response)  { // do something with response.session });  </script>
JavaScript SDK(9) – Event Handling FB.Event.unsubscribe Removing a subscriber is basically the same as adding one <script>  var onSessionChange = function(response) { // do something with response.session };  FB.Event.subscribe('auth.sessionChange', onSessionChange);  FB.Event.unsubscribe('auth.sessionChange', onSessionChange);  </script>
JavaScript SDK(10) – Data Access FB.Data.query Removing a subscriber is basically the same as adding one FB.Data.waitOn Wait until the results of all queries are ready <script>  var onSessionChange = function(response) { // do something with response.session };  FB.Event.subscribe('auth.sessionChange', onSessionChange);  FB.Event.unsubscribe('auth.sessionChange', onSessionChange);  </script>
JavaScript SDK(11) - Canvas Methods FB.Canvas.setAutoResize Starts or stops a timer which resizes your iframe every few milliseconds. FB.Canvas.setSize Tells Facebook to resize your iframe.
APPS ON FACEBOOK.COM Facebook
A PPS   ON  F ACEBOOK . COM
ARCHITECTURE Facebook
W HAT  F ACEBOOK  P ROVIDES  N OW FBML Canvas Applications Information Flow
W HAT  F ACEBOOK  P ROVIDES  N OW Websites and IFrame Canvas Applications Information Flow
Register facebook application
Register facebook application -  基本資料
Register facebook application –  驗證 參數 說明 Installable to? 什麼可以使用應用程式,共有兩種選擇,分別是個人檔案和粉絲專頁。 Post-Authorize Callback URL 當使用者第一次新增應用程式後,呼叫的網址。 Post-Remove Callback URL 當使用者移除應用程式後,呼叫的網址。
Register facebook application – 個人檔案 參數 說明 標籤名稱 顯示在個人檔案頁籤的名稱。 標籤網址 當點選頁籤時所載入的網址。 Post-Remove Callback URL 當使用者移除應用程式後,呼叫的網址。
Register facebook application – 個人檔案
Register facebook application – 個人檔案 參數 說明 發佈文字 位於朋友的個人檔案頁面中發佈器所顯示之標題文字。 發佈回呼網址 當在朋友的個人檔案發佈資訊時所呼叫的網址。 自我發佈文字 位於使用者本人的個人檔案頁面中發佈器所顯示之標題文字。 自我發佈回呼網址 當在使用者本人的個人檔案發佈資訊時所呼叫的網址。
Register facebook application –  畫布 參數 說明 畫布頁面網址 設定將應用程式的畫布網址,基本上,這算是應用程式的首頁網址。只要沒有其他應用程式指定的字串,我們可以將該字串設定為畫布網址。 Canvas Callback URL 應用程式真正的網址。 Post-Authorize Redirect URL 當使用者第一次確認應用程式導向的頁面,預設值為畫布頁面網址。 呈現方法 可選則 FBML 或 Iframe 。 IFrame  大小 當選擇 IFrame 時可設定其大小。 畫布寬度 當選擇畫布時可設定其大小。
Authentication Canvas applications use cookies to get user authentication information. The cookie includes a signature for all the values as the argument sig.
Integration Points Stream publishing Requests Bookmarks and Counters Application and Games dashboards Profile tabs
Stram publishing
Request Using FBML tags you can render request forms and friend selectors.
Bookmark, Counters, Game Dashboard, Profile Tab <fb:bookmark></fb:bookmark>
FACEBOOK QUERY LANGUAGE Facebook
FQL(1) Facebook Query Language  Enables we to use a SQL-style interface to query the data https://api.facebook.com/method/fql.query?query=QUERY. Table
FQL(2) – Testing Tool http://developers.facebook.com/docs/reference/rest/fql.query
FQL(3) –   支援基本的運算字 參數 說明 + 加法 - 減法 * 乘法 / 除法 > 大於 < 小於 >= 大於等於 <= 小於等於 = 等於 AND 及 OR 或 NOT 不是
FQL(4) –  支援的函式 參數 說明 now() 取得現在的時間。 rand() 產生亂數。 strlen(string) 計算字串長度。 concat(string, ...) 合併本函式中的所有字串。 substr(string, start, length) 根據字串開始位置 start 和取得長度 length 兩個參數,取得 string 字串的部份文字。 strpos(haystack, needle) 搜尋 haystack 字串,找出該字串中第一次出現 needle 字串的位置,若找不到符合 needle 字串的文字,則回傳 -1 。 lower(string) 將字串轉換成小寫。 upper(string) 將字串轉換成大寫。
FQL(5) – Table :  link_stat Query this table to return detailed information from your Facebook Share implementation SELECT share_count, like_count, comment_count, total_count,click_count FROM link_stat WHERE url=&quot;http://www.yahoo.com&quot;
FQL(6) – Table :  friend Query this table to determine whether two users are linked together as friends. 確認 uid1 跟 uid2 是否為朋友,若雙方不是朋友,將會取得空字串。 select uid1,uid2 from friend where uid1=4 and uid2=5 取得 uid1 的朋友清單 select uid1,uid2 from friend where uid1= 登入者的 UID
FQL(7) – Tables stream SELECT actor_id, message FROM stream WHERE source_id = <user id> limit 5 photo_tag SELECT pid FROM photo_tag WHERE subject=$uid photo SELECT src_big FROM photo WHERE pid IN ( SELECT pid FROM photo_tag WHERE subject=$uid )
FBML Facebook
FBML(1) FBML enables you to build Facebook applications that deeply integrate into a user's Facebook experience.
FBML(2) Tools User/Groups Notifications and Requests Platform Internationalization Status Messages Page Navigation Wall Visibility on Profile Profile-specific Misc Editor Display Embedded Media Dialog Additional Permissions Social Widgets Message Attachments Forms
FBML(3) <fb: 語法名稱 參數一 =&quot; 參數值 &quot;  參數二 =&quot; 參數值 &quot;  ‧‧‧ > 傳入內容 </fb: 語法名稱 >
FBML(4)
FBML(5) http://developers.facebook.com/docs/reference/fbml/ http://developers.facebook.com/tools/console/
FBML(6) <fb:bookmark></fb:bookmark> <fb:comments xid=&quot;titans_comments&quot; canpost=&quot;true&quot; candelete=&quot;false&quot; returnurl=&quot;http://apps.facebook.com/myapp/titans/&quot;></fb:comments>
OLD REST API The old REST API is the previous version of the Graph API.  If we are new to the Facebook Platform, Facebook recommend you use our new Graph API instead. Administrative Methods Login/Auth Methods Data Retrieval Methods Publishing Methods Facebook Connect Methods Mobile Methods Dashboard API Methods Events API Methods Custom Tags API Methods https://api.facebook.com/method/xxxx?access_token=
M OBILE   APPS iPhone SDK Android SDK
M OBILE   APPS - iPhone

Happy facebook developer

  • 1.
    H APPY F ACEBOOK D EVELOPER
  • 2.
    O UTLINE Self-Introduction History and Trends The Resource we need to know What Facebook Provide Now What languages We use in this offering Add Facebook to my site Apps on Facebook.com Mobile apps
  • 3.
  • 4.
  • 5.
    H ISTORY AND S TATICS 2004/2    Mark Zuckerberg launch Facebook
  • 6.
    H ISTORY AND S TATICS 2007/10  Facebook reaches over  50 million active users 2004/2    Mark Zuckerberg launch Facebook
  • 7.
    H ISTORY AND S TATICS 2008/8    Facebook reaches over 100 million active users 2007/10  Facebook reaches over  50 million active users 2004/2    Mark Zuckerberg launch Facebook
  • 8.
    H ISTORY AND S TATICS 2009/9    Facebook reaches over 300 million active users 2009/2    Facebook reaches over 200 million active users 2008/8    Facebook reaches over 100 million active users 2007/10  Facebook reaches over  50 million active users 2004/2    Mark Zuckerberg launch Facebook
  • 9.
    H ISTORY AND S TATICS 2010/2    Facebook reaches over 400 million active users 2009/12  Facebook reaches over 350 million active users 2009/9    Facebook reaches over 300 million active users 2009/2    Facebook reaches over 200 million active users 2008/8    Facebook reaches over 100 million active users 2007/10  Facebook reaches over  50 million active users 2004/2    Mark Zuckerberg launch Facebook
  • 10.
    H ISTORY AND S TATICS 全球有 四億多 會員,台灣則有 650 萬
  • 11.
    H ISTORY AND S TATICS 有 50% 的會員,每天會造訪 Facebook
  • 12.
    H ISTORY AND S TATICS 所有會員每個月花超過 5000 億 分鐘在 Facebook 上
  • 13.
    H ISTORY AND S TATICS Facebook 上有 1.6 億 個物件與會員進行互動
  • 14.
    H ISTORY AND S TATICS Facebook 有超過 70 種語系 版本
  • 15.
    H ISTORY AND S TATICS 有約 70% 的 Facebook 會員來自美國以外
  • 16.
    H ISTORY AND S TATICS 有超過 100 萬 個網站和 Facebook 整合
  • 17.
    H ISTORY AND S TATICS Facebook 有超過 55 萬 個 Apps
  • 18.
    H ISTORY AND S TATICS 每月有 70% 的會員用使用 Apps
  • 19.
    H ISTORY AND S TATICS 有超過 100 萬 的會員透過手機連到 Facebook
  • 20.
    H ISTORY AND S TATICS
  • 21.
    Sony Pictures hasreleased the first trailer for the upcoming movie, “The Social Network”, which is loosely based (sensationalized) on the history of Facebook http://www.thesocialnetwork-movie.com/ http://www.youtube.com/watch?v=mWoUgftTj3Y
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
    THE RESOURCE WENEED TO KNOW Facebook
  • 27.
    T HE R ESOURCE W E NEED TO KNOW Facebook Developer Wiki  http://wiki.developers.facebook.com/index.php/Main_Page Facebook developers Site  http://developers.facebook.com/  Developer Blog http://developers.facebook.com/blog/  All Facebook http://www.allfacebook.com/ Inside Facebook http://www.insidefacebook.com/ http://www.facebook.com/developers/ Tools Firefox Firebug http://developers.facebook.com/tools/
  • 28.
    W HAT LANGUAGES W E USE IN THIS OFFERING Javascript PHP And we will also take a look at Facebook iPhone API
  • 29.
    W HAT LANGUAGES W E USE IN THIS OFFERING But We Don’t discuss the skill for JavaScript, PHP, Objective-C, etc.
  • 30.
    Big Event f8developer conference on April 21, 2010.
  • 31.
    W HAT F ACEBOOK P ROVIDES N OW Facebook for Website Apps on Facebook.com Mobile Apps
  • 32.
    A DD F ACEBOOK TO MY WEBSITE Facebook
  • 33.
    A DD F ACEBOOK TO MY WEBSITE Social Plugins Single Sign-on Graph API Open Graph Protocol Analytics Platform showcase
  • 34.
  • 35.
    S OCIAL P LUGINS
  • 36.
    S OCIAL P LUGINS The easiest way to get started with Facebook Platform. We Can Use iframe or XFBML method  Sample Code (iframe) <iframe src=&quot;http://www.facebook.com/widgets/like.php?href= http://example.com &quot; scrolling=&quot;no&quot; frameborder=&quot;0&quot; style=&quot;border:none; width:450px; height:80px&quot;></iframe>
  • 37.
  • 38.
  • 39.
    Single Sign-on Oauth2.0 protocol http://tools.ietf.org/html/draft-ietf-oauth-v2-08 http://hueniverse.com/2010/05/introducing-oauth-2-0/ We Can get basically: All general information: like name, profile picture, gender and network. We can get more Ask extended Permisson http://developers.facebook.com/docs/authentication/permissions JavaScript SDK is a simple way <div id=&quot;fb-root&quot;></div> <script src=&quot;http://connect.facebook.net/en_US/all.js&quot;></script> <script> FB.init({appId: ' your app id ', 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>
  • 40.
    Single Sign-on Howto and Flow Register Our App http://tools.ietf.org/html/draft-ietf-oauth-v2-08 http://hueniverse.com/2010/05/introducing-oauth-2-0/ Redirect the user to https://graph.facebook.com/oauth/authorize with client_id After the user authorizes your application, Facebook redirects the user to the callback URL you specified with the access token in the URL fragment: Use the access token returned by the request above to fetch data from the Graph API on behalf of the user.
  • 41.
    Extended Permission RegisterOur App http://tools.ietf.org/html/draft-ietf-oauth-v2-08 http://hueniverse.com/2010/05/introducing-oauth-2-0/ http://developers.facebook.com/docs/authentication/permissions
  • 42.
  • 43.
  • 44.
    Graph API (1)- get data https://graph.facebook.com/ID
  • 45.
    Graph API (2)- get data https://graph.facebook.com/ID/CONNECTION_TYPE
  • 46.
    Graph API (3)- selection, Introspection https://graph.facebook.com/ID?fields=A,B,C... https://graph.facebook.com/?ids=XXX,YYY
  • 47.
    Graph API (4)POST We can publish to the Facebook graph by issuing HTTP POST requests to the appropriate connection URLs
  • 48.
    Graph API (5)Delete We can delete objects in the graph by issuing HTTP DELETE requests to the object DELETE https://graph.facebook.com/ID?access_token=... HTTP/1.1 OR https://graph.facebook.com/COMMENT_ID?method=delete
  • 49.
    Graph API (6)Search We can search over all public objects https://graph.facebook.com/search?q=QUERY&type=OBJECT_TYPE For Example All public posts: https://graph.facebook.com/search?q=watermelon&type=post People: https://graph.facebook.com/search?q=mark&type=user Pages: https://graph.facebook.com/search?q=platform&type=page Events: https://graph.facebook.com/search?q=conference&type=event Groups: https://graph.facebook.com/search?q=programming&type=group
  • 50.
    Graph API (7)Tool Graph API reference http://developers.facebook.com/docs/reference/api/
  • 51.
    Graph API (8)Tools CURL Javascript
  • 52.
  • 53.
  • 54.
    Introduction – frominsidefacebook.com
  • 55.
  • 56.
  • 57.
  • 58.
  • 59.
  • 60.
  • 61.
  • 62.
    JavaScript SDK(1) TheJavaScript SDK enables you to access all of the features of the Graph API via JavaScript The JavaScript SDK is also necessary to use the XFBML Must register your application. The SDK is open source and is available on http://github.com/facebook/connect-js
  • 63.
    JavaScript SDK(2) CoreMethods Event Handling XFBML Methods Data Access Utilities Canvas Methods
  • 64.
    JavaScript SDK(3) –Core Methods FB.api Make a API call <script> FB.api('/me', function(response) {   console.log(response); }); </script>
  • 65.
    JavaScript SDK(4) –Core Methods FB.getLoginStatus Find out the current status from the server, and get a session if the user is connected. <script> FB.getLoginStatus(function(response) {   if (response.session) {     alert('Coneected');   } else {     alert('No Coneected');   } }); </script>
  • 66.
    JavaScript SDK(5) –Core Methods FB.login Login/Authorize/Permissions. <button id=&quot;fb-login&quot;>Login</button> <script> document.getElementById('fb-login').onclick = function() {   FB.login(function(response) {     Log.info('FB.login callback', response);     if (response.session) {       Log.info('User is logged in');     } else {       Log.info('User is logged out');     }   }); }; </script>
  • 67.
    JavaScript SDK(6) –Core Methods FB.logout Logout the user in the background. <button id=&quot;fb-logout&quot;>Logout</button> <script> document.getElementById('fb-logout').onclick = function() {   FB.logout(function(response) {     alert('logout!');   // user is now logged out   }); }; </script>
  • 68.
    JavaScript SDK(7) –Core Methods FB.ui Method for triggering UI interaction with Facebook as IFrame dialogs or popups, like publishing to the stream, sharing links. <script>  var share = {    method: 'stream.share',    u: 'http://www.cht.com.tw/'  };  FB.ui(share, function(response) { console.log(response); }); </script>
  • 69.
    JavaScript SDK(8) –Event Handling FB.Event.subscribe Subscribe to a given event name, invoking your callback function whenever the event is fired. <script> FB.Event.subscribe('auth.sessionChange', function(response) { // do something with response.session }); </script>
  • 70.
    JavaScript SDK(9) –Event Handling FB.Event.unsubscribe Removing a subscriber is basically the same as adding one <script> var onSessionChange = function(response) { // do something with response.session }; FB.Event.subscribe('auth.sessionChange', onSessionChange); FB.Event.unsubscribe('auth.sessionChange', onSessionChange); </script>
  • 71.
    JavaScript SDK(10) –Data Access FB.Data.query Removing a subscriber is basically the same as adding one FB.Data.waitOn Wait until the results of all queries are ready <script> var onSessionChange = function(response) { // do something with response.session }; FB.Event.subscribe('auth.sessionChange', onSessionChange); FB.Event.unsubscribe('auth.sessionChange', onSessionChange); </script>
  • 72.
    JavaScript SDK(11) -Canvas Methods FB.Canvas.setAutoResize Starts or stops a timer which resizes your iframe every few milliseconds. FB.Canvas.setSize Tells Facebook to resize your iframe.
  • 73.
  • 74.
    A PPS ON F ACEBOOK . COM
  • 75.
  • 76.
    W HAT F ACEBOOK P ROVIDES N OW FBML Canvas Applications Information Flow
  • 77.
    W HAT F ACEBOOK P ROVIDES N OW Websites and IFrame Canvas Applications Information Flow
  • 78.
  • 79.
  • 80.
    Register facebook application– 驗證 參數 說明 Installable to? 什麼可以使用應用程式,共有兩種選擇,分別是個人檔案和粉絲專頁。 Post-Authorize Callback URL 當使用者第一次新增應用程式後,呼叫的網址。 Post-Remove Callback URL 當使用者移除應用程式後,呼叫的網址。
  • 81.
    Register facebook application– 個人檔案 參數 說明 標籤名稱 顯示在個人檔案頁籤的名稱。 標籤網址 當點選頁籤時所載入的網址。 Post-Remove Callback URL 當使用者移除應用程式後,呼叫的網址。
  • 82.
  • 83.
    Register facebook application– 個人檔案 參數 說明 發佈文字 位於朋友的個人檔案頁面中發佈器所顯示之標題文字。 發佈回呼網址 當在朋友的個人檔案發佈資訊時所呼叫的網址。 自我發佈文字 位於使用者本人的個人檔案頁面中發佈器所顯示之標題文字。 自我發佈回呼網址 當在使用者本人的個人檔案發佈資訊時所呼叫的網址。
  • 84.
    Register facebook application– 畫布 參數 說明 畫布頁面網址 設定將應用程式的畫布網址,基本上,這算是應用程式的首頁網址。只要沒有其他應用程式指定的字串,我們可以將該字串設定為畫布網址。 Canvas Callback URL 應用程式真正的網址。 Post-Authorize Redirect URL 當使用者第一次確認應用程式導向的頁面,預設值為畫布頁面網址。 呈現方法 可選則 FBML 或 Iframe 。 IFrame 大小 當選擇 IFrame 時可設定其大小。 畫布寬度 當選擇畫布時可設定其大小。
  • 85.
    Authentication Canvas applicationsuse cookies to get user authentication information. The cookie includes a signature for all the values as the argument sig.
  • 86.
    Integration Points Streampublishing Requests Bookmarks and Counters Application and Games dashboards Profile tabs
  • 87.
  • 88.
    Request Using FBMLtags you can render request forms and friend selectors.
  • 89.
    Bookmark, Counters, GameDashboard, Profile Tab <fb:bookmark></fb:bookmark>
  • 90.
  • 91.
    FQL(1) Facebook QueryLanguage Enables we to use a SQL-style interface to query the data https://api.facebook.com/method/fql.query?query=QUERY. Table
  • 92.
    FQL(2) – TestingTool http://developers.facebook.com/docs/reference/rest/fql.query
  • 93.
    FQL(3) – 支援基本的運算字 參數 說明 + 加法 - 減法 * 乘法 / 除法 > 大於 < 小於 >= 大於等於 <= 小於等於 = 等於 AND 及 OR 或 NOT 不是
  • 94.
    FQL(4) – 支援的函式 參數 說明 now() 取得現在的時間。 rand() 產生亂數。 strlen(string) 計算字串長度。 concat(string, ...) 合併本函式中的所有字串。 substr(string, start, length) 根據字串開始位置 start 和取得長度 length 兩個參數,取得 string 字串的部份文字。 strpos(haystack, needle) 搜尋 haystack 字串,找出該字串中第一次出現 needle 字串的位置,若找不到符合 needle 字串的文字,則回傳 -1 。 lower(string) 將字串轉換成小寫。 upper(string) 將字串轉換成大寫。
  • 95.
    FQL(5) – Table: link_stat Query this table to return detailed information from your Facebook Share implementation SELECT share_count, like_count, comment_count, total_count,click_count FROM link_stat WHERE url=&quot;http://www.yahoo.com&quot;
  • 96.
    FQL(6) – Table: friend Query this table to determine whether two users are linked together as friends. 確認 uid1 跟 uid2 是否為朋友,若雙方不是朋友,將會取得空字串。 select uid1,uid2 from friend where uid1=4 and uid2=5 取得 uid1 的朋友清單 select uid1,uid2 from friend where uid1= 登入者的 UID
  • 97.
    FQL(7) – Tablesstream SELECT actor_id, message FROM stream WHERE source_id = <user id> limit 5 photo_tag SELECT pid FROM photo_tag WHERE subject=$uid photo SELECT src_big FROM photo WHERE pid IN ( SELECT pid FROM photo_tag WHERE subject=$uid )
  • 98.
  • 99.
    FBML(1) FBML enablesyou to build Facebook applications that deeply integrate into a user's Facebook experience.
  • 100.
    FBML(2) Tools User/GroupsNotifications and Requests Platform Internationalization Status Messages Page Navigation Wall Visibility on Profile Profile-specific Misc Editor Display Embedded Media Dialog Additional Permissions Social Widgets Message Attachments Forms
  • 101.
    FBML(3) <fb: 語法名稱參數一 =&quot; 參數值 &quot; 參數二 =&quot; 參數值 &quot; ‧‧‧ > 傳入內容 </fb: 語法名稱 >
  • 102.
  • 103.
  • 104.
    FBML(6) <fb:bookmark></fb:bookmark> <fb:commentsxid=&quot;titans_comments&quot; canpost=&quot;true&quot; candelete=&quot;false&quot; returnurl=&quot;http://apps.facebook.com/myapp/titans/&quot;></fb:comments>
  • 105.
    OLD REST APIThe old REST API is the previous version of the Graph API. If we are new to the Facebook Platform, Facebook recommend you use our new Graph API instead. Administrative Methods Login/Auth Methods Data Retrieval Methods Publishing Methods Facebook Connect Methods Mobile Methods Dashboard API Methods Events API Methods Custom Tags API Methods https://api.facebook.com/method/xxxx?access_token=
  • 106.
    M OBILE APPS iPhone SDK Android SDK
  • 107.
    M OBILE APPS - iPhone

Editor's Notes

  • #6 Facebook 的創辦人是 馬克 · 扎克伯格 ( Mark Zuckerberg ),他是 哈佛大學 的學生,之前畢業於 阿茲利高中 (英語: Ardsley High School )。 Facebook 的名字是來自傳統的紙質「花名冊」,通常美國的大學和預科學校把這種印有學校社區所有成員的「花名冊」發放給新入學或入職的學生和教職 員,協助大家認識學校內其他成員。最初, Facebook 的註冊僅限於 哈佛學院 的學生,在隨後的兩個月內,註冊擴展至 波士頓 地區的其他高校(如 麻省理工學院 )以及 史丹福大學 、 紐約大學 、 西北大學 和所有的 長春藤名校 。第二年,很多其他學校也被邀請加入。最終,在全球範圍內有 一個大學後綴電子郵箱的人(如 .edu, .ac.uk 等)都可以註冊。之後,在 Facebook 中也可以建立起高中和公司的社會化網路。而從 2006 年 9 月 11 日起,任何用戶輸入有效電子郵件位 址都可申請。用戶可以選擇加入一個或以上網路,例如中學的、公司的、或地區。 [6]