Tích hợp trao đổi dữ liệu với Facebook By: Nguyễn Mạnh Tiến Tầm tay
Agenda• FB connection• FB graph API• How work?• Technical steps• FB and Open Social
Facebook overviewMore than 800 million active usersMore than 60 million Connect users monthlyAbout 83% people trust their friends over any other source.Facebook users engaged withfacebook on 2.5M websites everymonthAbout 36 TB/day
Facebook connection?λ The next evolution of Facebook Platformλ It enables the integration of the Facebook Platform into your own site, allowing your users to:– Seamlessly "connect" their Facebook account andinformation with your site– Connect and find their friends who also use your site– Share information and actions on your site with theirfriends on Facebook through their profile pages &newsfeeds
Facebook to my site?• Identity: Seamlessly connect the users Facebook account andinformation with your site.• Friends: Bring a users Facebook friends into your site. You caneven link friends that have existing accounts.• Discovery: Publish information back into their friends NewsFeeds on Facebook.• Privacy: Bring dynamic privacy to your site.• Reliability: The full power and flexibility of FacebookPlatform.
Should Use Facebook Connect?• One-click Login: Allow users to log in with their Facebook identity andallow your site to access their Facebook profile information.• Increased engagement: Leverage users personal interests to show morerelevant information and surface personalized content from friends suchas reviews or comments.• New forms of distribution: Users can share content and actions taken onyour site with friends back on Facebook through feed, invites, and othersocial communication channels on Facebook.
Facebook Graph API?– Facebooks core– Presents a simple, consistent view of the Facebook social graph– Every object in the social graph has a unique ID. You can access the properties of an object by requesting https://graph.facebook.com/ID– People and pages with usernames can be accessed using their username as an ID– All responses are JSON objects– Relationships– Reading, Searching, Publishing, Deleting, Analytics
First step• Yêu cầu chung: YOUR_APP_ID• đăng ký với FB để lấy mã ID tương tác với ứng dụng của FB (FaceBook API)• http://developers.facebook.com/setup/
ReadingUsing access token key, issuing HTTP GET requests , return data in jsonví dụ truy cập feed :https://graph.facebook.com/id/feed?access_token=2227470867|2.AQA_W4-fDdlG-erj.3600.1306126800.0-1090002606|Ktp_XdsULJo0j-CAaUratCxJKqMPhp code:<?php$readfeed_url = sprintf(https://graph.facebook.com/%d/feed?access_token=%s,$fbdata[fbid], $fbdata[access_token] ) ;$feed = json_decode(file_get_contents($readfeed_url));?>
PublishingUsing access token key: issuing HTTP POST requestsPhp code tương ứng :<?php$token = 3523452345.....$message = "Hello, Arjun. I like this new API";$uid = arjun$url = https://graph.facebook.com/$uid/feed?access_token=$token&message=$message&method=post$result = file_get_contents($url);?>
Market Size and Competition• Ideally speaking, OpenSocial has a market potential for 250 million users as opposed to 64 million active users on Facebook• 15,000 Applications on Facebook. Difficult to rapidly grow user base due to a saturated market• Most existing Google Widgets can run on OpenSocial. Results? Difficult to rapidly grow user base due to existing competition
FB and Open social• The choice of your platform should depend on demographic• OpenSocial is modeled after Facebook. So if you’ve built a Facebook application before, it is relatively easy to learn OpenSocial• “Write Once, Run Anywhere” is not exactly true. An Orkut specific OpenSocial app. Might not necessairly run on Hi5
Resources• Getting Started Guide: http://wiki.developers.facebook.com/index.php/Trying_Out_Facebook_Con nect• Facebook Connect Policies: http://wiki.developers.facebook.com/index.php/Facebook_Connect_Policies• Facebook Connect: Developers Centralhttp://developers.facebook.com/docs/• Graph APIhttp://graph.facebook.com/• Websites using Facebook Connect sorted by active monthly users http://www.allfacebook.com•Opensocialhttp://code.google.com/apis/opensocial/