SlideShare a Scribd company logo
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 overview
About 400 million monthly
  active users
About 60 million Connect users
About 83% people trust their
  friends over any other
  source.
About 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 and
information with your site
– Connect and find their friends who also use your site
– Share information and actions on your site with their
friends on Facebook through their profile pages &
newsfeeds
Facebook to my site?


• Identity: Seamlessly connect the user's Facebook account and
information with your site.
• Friends: Bring a user's Facebook friends into your site. You can
even link friends that have existing accounts.
• Discovery: Publish information back into their friends' News
Feeds on Facebook.
• Privacy: Bring dynamic privacy to your site.
• Reliability: The full power and flexibility of Facebook
Platform.
Should Use Facebook Connect?

• One-click Login: Allow users to log in with their Facebook identity and
allow your site to access their Facebook profile information.

• Increased engagement: Leverage users' personal interests to show more
relevant information and surface personalized content from friends such
as reviews or comments.

• New forms of distribution: Users can share content and actions taken on
your site with friends back on Facebook through feed, invites, and other
social communication channels on Facebook.
Facebook core
Facebook Graph API?

– Facebook's 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
Object
https://graph.facebook.com/platform
Relationships
https://graph.facebook.com/ID/CONNECTION_TYPE
How does it work?
Connect
Interactive with Facebook
Technical steps
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/
Next step : Authentication

    Authenticate on your site (out of FB). Method of authentication :
in code - server side : The server-side flow is used whenever you need to call the
    Graph API from your web server
in html - client side : The client-side flow is used when you need to make calls to
    the Graph API from a client, such as JavaScript running in a Web browser or
    from a native mobile or desktop app

    Iusse request :
https://www.facebook.com/dialog/oauth?
client_id=YOUR_APP_ID&redirect_uri=YOUR_URL&scope=email,read_stream

    Return code to get access token key:
Kết thúc Authentication thì FB sẽ trả về code để lấy token code và access vào
   graph protocol của FB để lấy các loại dữ liệu khác
nguồn tham khảo : http://developers.facebook.com/docs/authentication
Reading
Using access token key, issuing HTTP GET requests , return data in json
ví 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-CAaUratCxJKqM


Php 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));
?>
Publishing
Using access token key: issuing HTTP POST requests




Php 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);
?>
Alternatively, OpenSocial
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
Technical Differences


• Facebook requires proprietary languages (FBML, FQL,
  FBJS). Google requires XML and JavaScript

• Google provides an IDE (aka Google Gadget Editor)

• Google hosts applications for free. Facebook doesn’t
Language Support
Facebook API                   OpenSocial API
•   FBML                       •   XHTML/XML
•   FQL                        •   JavaScript
•   FBJS                       •   Full Support for AJAX
•   Partial support for AJAX   •   Backend languages like
•   Backend languages like         PHP, Java, .NET on
    PHP, Java, .NET on             Canvas
    Canvas
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_Conne
ct
• Facebook Connect Policies:
http://wiki.developers.facebook.com/index.php/Facebook_Connect_Policies
• Facebook Connect: Developers Central
http://developers.facebook.com/docs/
• Graph API
http://graph.facebook.com/
• Websites using Facebook Connect sorted by active monthly users
 http://www.allfacebook.com
•Opensocial
http://code.google.com/apis/opensocial/
Thank you


Nguyễn Mạnh Tiến
tien.nguyen@tamtay.vn
www.tamtay.vn

More Related Content

PDF
Interactive with-facebook
PDF
[Code Camp] Ứng dụng Facebook API vào phát triển website
PPT
Facebook API in the Real World - Myles Noton - Miniclip
PPT
Facebook api
PDF
Leveraging Rails to Build Facebook Apps
PPTX
Alphageeks meetup - facebook api
PDF
Facebook Python SDK - Introduction
PDF
Building Facebook Apps
Interactive with-facebook
[Code Camp] Ứng dụng Facebook API vào phát triển website
Facebook API in the Real World - Myles Noton - Miniclip
Facebook api
Leveraging Rails to Build Facebook Apps
Alphageeks meetup - facebook api
Facebook Python SDK - Introduction
Building Facebook Apps

What's hot (16)

PDF
Facebook API for iOS
PDF
Facebook API for Developers : Introducing the Facebook Platform
PDF
Introduction to Facebook Javascript SDK (NEW)
PPT
How to develop app for facebook fan page
KEY
페이스북 소셜 앱 개발 가이드 2011
PPTX
Developers Tools: An overview of Facebook Development
PPTX
Download PowerPoint Project on social programming for engineering students
KEY
OAuth Introduction
PPT
Web 2.0
PPTX
Automating Site Provisioning in SharePoint - Presented 7/27/13 at SharePoint ...
PPTX
My Sites in SharePoint 2010
PPTX
Introduction to facebook platform
PDF
Peepcode facebook-2-rails on facebook
PPTX
Joomunited social backlinks
PDF
"Leveraging SharePoint for Project Management" for SPTech Conference SFO
PDF
7 Ways To Leverage SharePoint for Project Management Success
Facebook API for iOS
Facebook API for Developers : Introducing the Facebook Platform
Introduction to Facebook Javascript SDK (NEW)
How to develop app for facebook fan page
페이스북 소셜 앱 개발 가이드 2011
Developers Tools: An overview of Facebook Development
Download PowerPoint Project on social programming for engineering students
OAuth Introduction
Web 2.0
Automating Site Provisioning in SharePoint - Presented 7/27/13 at SharePoint ...
My Sites in SharePoint 2010
Introduction to facebook platform
Peepcode facebook-2-rails on facebook
Joomunited social backlinks
"Leveraging SharePoint for Project Management" for SPTech Conference SFO
7 Ways To Leverage SharePoint for Project Management Success
Ad

Viewers also liked (7)

PDF
Mobilemonday.vn mobile interaction - mr ng cuu long goldsun focus media
PPTX
Facebook API
PPTX
Hướng dẫn cách tăng like facebook tự động
PDF
Cách sử dụng tên miền thật khi chạy website ở localhost
PDF
Lập trình và thiết kế website tương tác với facebook tập 1
PDF
Làm thế nào để tăng 10.000 like trong 7 ngày
PDF
Hướng dẫn quản trị Facebook Fanpage
Mobilemonday.vn mobile interaction - mr ng cuu long goldsun focus media
Facebook API
Hướng dẫn cách tăng like facebook tự động
Cách sử dụng tên miền thật khi chạy website ở localhost
Lập trình và thiết kế website tương tác với facebook tập 1
Làm thế nào để tăng 10.000 like trong 7 ngày
Hướng dẫn quản trị Facebook Fanpage
Ad

Similar to Php day 2011 - Interactive-with-facebook (20)

PDF
Facebook Open Graph API and How To Use It
PPTX
Oauth
PPTX
Buiding application for social networks
PDF
Open Graph API And How To Use It : Facebook Developers Circle Meetup 2017
PPS
Virtual Tech Days 2010 - Integrating Social Networks with ASP.NET
PPTX
Facebook Open Graph Protocol and Graph API (NoVA Code Camp 2010.1)
PPT
Facebook API
PPTX
The Flash Facebook Cookbook - FlashMidlands
PDF
Integrating OpenSocial & SalesForce.com
PDF
Mashing up JavaScript
PDF
international PHP2011_Bastian Hofmann_Mashing up java script
PDF
Introduction to Facebook Python API
PPTX
Navigating OAuth and OIDC: From Access Tokens to SSO
PDF
Server-side Java Programming
PPT
The social media developer
PDF
Facebook Connect Tutorial
ODP
Kt 15 07-2013
PDF
Socializing your-site-with-facebook-connect-1233555047748651-1
Facebook Open Graph API and How To Use It
Oauth
Buiding application for social networks
Open Graph API And How To Use It : Facebook Developers Circle Meetup 2017
Virtual Tech Days 2010 - Integrating Social Networks with ASP.NET
Facebook Open Graph Protocol and Graph API (NoVA Code Camp 2010.1)
Facebook API
The Flash Facebook Cookbook - FlashMidlands
Integrating OpenSocial & SalesForce.com
Mashing up JavaScript
international PHP2011_Bastian Hofmann_Mashing up java script
Introduction to Facebook Python API
Navigating OAuth and OIDC: From Access Tokens to SSO
Server-side Java Programming
The social media developer
Facebook Connect Tutorial
Kt 15 07-2013
Socializing your-site-with-facebook-connect-1233555047748651-1

More from Quang Anh Le (20)

PPTX
Mobilemonday.vn adflex
PPTX
Mobilemonday.vn momo-monetize thinking_tu do tai chinh_v1.2
PDF
02 mobile monday hanoi april 2013 vinova
PPT
01 mobile monday hanoi april 2013 mobile game - afoli
PPTX
03 mobile monday hanoi april 2013 monetize thinking g mo m-work
PPT
2. minh chau momo t4
PPT
0. mobilemonday.vn hcm 20130424
PPT
Vietnam mobile day 2012 phan mem cho phai dep - mana
PPTX
Vietnam mobile day 2012 i os memory management - techmaster
PPTX
Vietnam mobile day 2012 monetizing mobile apps games - rubycell
PDF
Vietnam mobile day 2012 cuoc cach mang thoi ky hau mobile - misfit
PPTX
Vietnam mobile day 2012 multi platform development - game loft
PDF
Vietnam mobile day 2012 developer opportunity - nokia
PPT
Vietnam mobile day 2012 building a mobile linux firmware for your router - ...
PPT
Vietnam mobile day 2012 ban quyen mobile contents - vsm
PDF
Vietnam mobile day 2012 platform mo va ung dung de phat trien mang xa hoi m...
PPT
Vietnam mobile day 2012 co hoi mobile tai vietnam - cyber agent
PPTX
Vietnam mobile day 2012 html5 game using impact js - aiti-aptech
PPTX
Vietnam mobile day 2012 tuong lai cho nha phat trien nds - share plus
PPSX
Vietnam mobile day 2012 trends in mobile marketing - fifth i media
Mobilemonday.vn adflex
Mobilemonday.vn momo-monetize thinking_tu do tai chinh_v1.2
02 mobile monday hanoi april 2013 vinova
01 mobile monday hanoi april 2013 mobile game - afoli
03 mobile monday hanoi april 2013 monetize thinking g mo m-work
2. minh chau momo t4
0. mobilemonday.vn hcm 20130424
Vietnam mobile day 2012 phan mem cho phai dep - mana
Vietnam mobile day 2012 i os memory management - techmaster
Vietnam mobile day 2012 monetizing mobile apps games - rubycell
Vietnam mobile day 2012 cuoc cach mang thoi ky hau mobile - misfit
Vietnam mobile day 2012 multi platform development - game loft
Vietnam mobile day 2012 developer opportunity - nokia
Vietnam mobile day 2012 building a mobile linux firmware for your router - ...
Vietnam mobile day 2012 ban quyen mobile contents - vsm
Vietnam mobile day 2012 platform mo va ung dung de phat trien mang xa hoi m...
Vietnam mobile day 2012 co hoi mobile tai vietnam - cyber agent
Vietnam mobile day 2012 html5 game using impact js - aiti-aptech
Vietnam mobile day 2012 tuong lai cho nha phat trien nds - share plus
Vietnam mobile day 2012 trends in mobile marketing - fifth i media

Recently uploaded (20)

PDF
NewMind AI Weekly Chronicles - August'25 Week I
PPTX
sap open course for s4hana steps from ECC to s4
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Empathic Computing: Creating Shared Understanding
PPTX
Big Data Technologies - Introduction.pptx
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PPTX
Spectroscopy.pptx food analysis technology
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Encapsulation theory and applications.pdf
PDF
KodekX | Application Modernization Development
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Chapter 3 Spatial Domain Image Processing.pdf
NewMind AI Weekly Chronicles - August'25 Week I
sap open course for s4hana steps from ECC to s4
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Empathic Computing: Creating Shared Understanding
Big Data Technologies - Introduction.pptx
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Spectroscopy.pptx food analysis technology
Building Integrated photovoltaic BIPV_UPV.pdf
Spectral efficient network and resource selection model in 5G networks
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Encapsulation theory and applications.pdf
KodekX | Application Modernization Development
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
MIND Revenue Release Quarter 2 2025 Press Release
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Encapsulation_ Review paper, used for researhc scholars
Diabetes mellitus diagnosis method based random forest with bat algorithm
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Chapter 3 Spatial Domain Image Processing.pdf

Php day 2011 - Interactive-with-facebook

  • 1. Tích hợp trao đổi dữ liệu với Facebook By: Nguyễn Mạnh Tiến Tầm tay
  • 2. Agenda • FB connection • FB graph API • How work? • Technical steps • FB and Open Social
  • 3. Facebook overview About 400 million monthly active users About 60 million Connect users About 83% people trust their friends over any other source. About 36 TB/day
  • 4. 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 and information with your site – Connect and find their friends who also use your site – Share information and actions on your site with their friends on Facebook through their profile pages & newsfeeds
  • 5. Facebook to my site? • Identity: Seamlessly connect the user's Facebook account and information with your site. • Friends: Bring a user's Facebook friends into your site. You can even link friends that have existing accounts. • Discovery: Publish information back into their friends' News Feeds on Facebook. • Privacy: Bring dynamic privacy to your site. • Reliability: The full power and flexibility of Facebook Platform.
  • 6. Should Use Facebook Connect? • One-click Login: Allow users to log in with their Facebook identity and allow your site to access their Facebook profile information. • Increased engagement: Leverage users' personal interests to show more relevant information and surface personalized content from friends such as reviews or comments. • New forms of distribution: Users can share content and actions taken on your site with friends back on Facebook through feed, invites, and other social communication channels on Facebook.
  • 8. Facebook Graph API? – Facebook's 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
  • 11. How does it work?
  • 15. 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/
  • 16. Next step : Authentication  Authenticate on your site (out of FB). Method of authentication : in code - server side : The server-side flow is used whenever you need to call the Graph API from your web server in html - client side : The client-side flow is used when you need to make calls to the Graph API from a client, such as JavaScript running in a Web browser or from a native mobile or desktop app  Iusse request : https://www.facebook.com/dialog/oauth? client_id=YOUR_APP_ID&redirect_uri=YOUR_URL&scope=email,read_stream  Return code to get access token key: Kết thúc Authentication thì FB sẽ trả về code để lấy token code và access vào graph protocol của FB để lấy các loại dữ liệu khác nguồn tham khảo : http://developers.facebook.com/docs/authentication
  • 17. Reading Using access token key, issuing HTTP GET requests , return data in json ví 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-CAaUratCxJKqM Php 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)); ?>
  • 18. Publishing Using access token key: issuing HTTP POST requests Php 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); ?>
  • 20. 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
  • 21. Technical Differences • Facebook requires proprietary languages (FBML, FQL, FBJS). Google requires XML and JavaScript • Google provides an IDE (aka Google Gadget Editor) • Google hosts applications for free. Facebook doesn’t
  • 22. Language Support Facebook API OpenSocial API • FBML • XHTML/XML • FQL • JavaScript • FBJS • Full Support for AJAX • Partial support for AJAX • Backend languages like • Backend languages like PHP, Java, .NET on PHP, Java, .NET on Canvas Canvas
  • 23. 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
  • 24. Resources • Getting Started Guide: http://wiki.developers.facebook.com/index.php/Trying_Out_Facebook_Conne ct • Facebook Connect Policies: http://wiki.developers.facebook.com/index.php/Facebook_Connect_Policies • Facebook Connect: Developers Central http://developers.facebook.com/docs/ • Graph API http://graph.facebook.com/ • Websites using Facebook Connect sorted by active monthly users http://www.allfacebook.com •Opensocial http://code.google.com/apis/opensocial/
  • 25. Thank you Nguyễn Mạnh Tiến tien.nguyen@tamtay.vn www.tamtay.vn