facebook python api
TRANSCRIPT
-
8/9/2019 facebook python api
1/29
-
8/9/2019 facebook python api
2/29
f
Objectives
• Learn the concepts of Facebook API
• Learn how to play with Facebook GraphAPI
-
8/9/2019 facebook python api
3/29
f
Core Topics
•Facebook Developers website
• Graph API• Facebook Python SDK
• Resources
-
8/9/2019 facebook python api
4/29
f
Facebook Developers
• Provide you online documentations• Forum for discussion
•Management of your applications
-
8/9/2019 facebook python api
5/29
f
Where is it?
-
8/9/2019 facebook python api
6/29
-
8/9/2019 facebook python api
7/29
f
Is That What You Want?
-
8/9/2019 facebook python api
8/29
f
Graph API
• Facebook’s core
• Social graph• Connections
Application Graph API Facebook Database
Access Token Request Data
Aggregate InformationResponse Data
-
8/9/2019 facebook python api
9/29
f
Graph Model
• Composed of objects and connections• Identify entities and relationships by id• Data will be stored with smallest spaces
and keep being updated
-
8/9/2019 facebook python api
10/29
f
Object Model
information from graph API
without access token
-
8/9/2019 facebook python api
11/29
f
Graph Model
information from graph APIwith access token
-
8/9/2019 facebook python api
12/29
f
Connection Model
• All of the object in the Facebook social graph are connectedto each other via connections
• Objects are just like entities while connections are likerelationship
•For example, users, pages and groups are objects and likes,
friends and feeds are connections
-
8/9/2019 facebook python api
13/29
f
Connection Model
-
8/9/2019 facebook python api
14/29
f
Access to Graph
• HTTP(S) Graph API
•SDKs
! Javascript SDK
! iOS SDK
! Android SDK
! PHP SDK
! Python SDK
-
8/9/2019 facebook python api
15/29
f
HTTP(S) Graph API
• RESTful HTTP request & response• Response data-type: JSON
•Access URL: graph.facebook.com
-
8/9/2019 facebook python api
16/29
f
HTTP(S) Graph API
• Request information of an object with id or username
• id-or-username can be “me” with the access token
!""#$%%&'(#!)*(+,-../)+.0%1234.'456,'7(0,8
http://graph.facebook.com/http://graph.facebook.com/
-
8/9/2019 facebook python api
17/29
f
HTTP(S) Graph API
9 ;23;$ ;
-
8/9/2019 facebook python api
18/29
-
8/9/2019 facebook python api
19/29
f
Get Access Token
• GetMyAccesshttp://getmyaccess.heroku.com
• It requires a permission called“offline_access”, so this token can be valid
for a long time
http://getmyaccess.heroku.com/http://getmyaccess.heroku.com/http://getmyaccess.heroku.com/
-
8/9/2019 facebook python api
20/29
-
8/9/2019 facebook python api
21/29
f
Python SDK
• Let you access all features of the Graph API• That’s all, let’s play!
-
8/9/2019 facebook python api
22/29
f
Python SDK
• https://github.com/facebook/python-sdk • Designed to support Graph API and FB
Javascript SDK (You will learn in the future)
https://github.com/facebook/python-sdkhttps://github.com/facebook/python-sdk
-
8/9/2019 facebook python api
23/29
f
Graph
• Depends your access token• Everyone will have their own graph, could
be unique
-
8/9/2019 facebook python api
24/29f
Graph API Class
• Fetch the graph by implement it
20#.'" *(+,-../
&'(#! O *(+,-../)P'(#!QRSTU
56,' O &'(#!)&,"I.-V,+"TWG2""G,KA@A?XU
-
8/9/2019 facebook python api
25/29f
Authentication
• Graph can be implemented with an accesstoken
• And the perspective of the graph will bediff erent
0YI#'.*2G, O &'(#!)&,"I.-V,+"TW0,XU
&'(#! O P'(#!QRSTQFFZHHI[\]Z^U
-
8/9/2019 facebook python api
26/29f
Graph Methods
• get_object, get_objects
• get_connections• put_object
•put_wall_post, put_comment, put_like
• delete_object
-
8/9/2019 facebook python api
27/29f
Demo
-
8/9/2019 facebook python api
28/29f
Homework
• Fetch a kind of data on the FB Graph• Do some statistics on it
•Don’t Copy from others
-
8/9/2019 facebook python api
29/29f
Q&A TimeThanks for your listening