Introduction to Facebook Python API
Social Network and Applications, 2011
LittleQ, The Department of Computer Science, NCCU




                                                    f
                                                         Introduction to
                                                        Facebook PY API
Objectives



•   Learn the concepts of Facebook API
•   Learn how to play with Facebook Graph
    API


                                     f
                                          Introduction to
                                         Facebook PY API
Core Topics

•   Facebook Developers website
•   Graph API
•   Facebook Python SDK
•   Resources



                                  f
                                       Introduction to
                                      Facebook PY API
Facebook Developers

•   Provide you online documentations
•   Forum for discussion
•   Management of your applications




                                      f
                                           Introduction to
                                          Facebook PY API
Where is it?




               f
                    Introduction to
                   Facebook PY API
Social Plugins


•   Like Button, Send Button, Login Button
•   Comments
•   Your Friends
•   Activity Feed, Live Stream

                                     f
                                          Introduction to
                                         Facebook PY API
Is That What You Want?



                  f
                       Introduction to
                      Facebook PY API
Graph API
              Response Data               Aggregate Information




              Access Token                    Request Data



Application                   Graph API                      Facebook Database


 •   Facebook’s core
 •   Social graph
 •   Connections


                                                                  f
                                                                       Introduction to
                                                                      Facebook PY API
Graph Model

•   Composed of objects and connections
•   Identify entities and relationships by id
•   Data will be stored with smallest spaces
    and keep being updated




                                        f
                                             Introduction to
                                            Facebook PY API
Object Model

information from graph API
   without access token




                               f
                                    Introduction to
                                   Facebook PY API
Graph Model
          information from graph API
               with access token




                f
                      Introduction to
                     Facebook PY API
Connection Model

•   All of the object in the Facebook social graph are connected
    to each other via connections

•   Objects are just like entities while connections are like
    relationship

•   For example, users, pages and groups are objects and likes,
    friends and feeds are connections




                                                       f
                                                            Introduction to
                                                           Facebook PY API
Connection Model




              f
                   Introduction to
                  Facebook PY API
Access to Graph
•   HTTP(S) Graph API
•   SDKs
    ‣   Javascript SDK

    ‣   iOS SDK

    ‣   Android SDK

    ‣   PHP SDK

    ‣   Python SDK




                         f
                              Introduction to
                             Facebook PY API
HTTP(S) Graph API

•   RESTful HTTP request & response
•   Response data-type: JSON
•   Access URL: graph.facebook.com




                                      f
                                           Introduction to
                                          Facebook PY API
HTTP(S) Graph API

http://graph.facebook.com/<id-­‐or-­‐username>



•   Request information of an object with id or username

•   id-or-username can be “me” with the access token




                                                f
                                                        Introduction to
                                                       Facebook PY API
HTTP(S) Graph API
           http://graph.facebook.com/littleq0903


Result:
    {
    	
  	
  	
  "id":	
  "1681390745",
    	
  	
  	
  "name":	
  "Colin	
  Su",
    	
  	
  	
  "first_name":	
  "Colin",
    	
  	
  	
  "last_name":	
  "Su",
    	
  	
  	
  "link":	
  "https://www.facebook.com/littleq0903",
    	
  	
  	
  "username":	
  "littleq0903",
    	
  	
  	
  "gender":	
  "male",
    	
  	
  	
  "locale":	
  "en_US"
    }



                                                             f
                                                                      Introduction to
                                                                     Facebook PY API
Access Token
•   A long string stands for the authentication of users

•   Temporary

•   The information behind the access token

    ‣ user id
    ‣ app id
    ‣ expired time
    ‣ secret


                                                  f
                                                       Introduction to
                                                      Facebook PY API
Get Access Token

•   GetMyAccess
    http://getmyaccess.heroku.com
•   It requires a permission called
    “offline_access”, so this token can be valid
    for a long time



                                       f
                                            Introduction to
                                           Facebook PY API
HTTP(S) Graph API

•   Access token should be transferred as a
    HTTP GET variable
http://graph.facebook.com/littleq0903?access_token=...


•   More information:
    developers.facebook.com/docs/reference/
    api/


                                              f
                                                   Introduction to
                                                  Facebook PY API
Python SDK



•   Let you access all features of the Graph API
•   That’s all, let’s play!


                                       f
                                            Introduction to
                                           Facebook PY API
Python SDK


•   https://github.com/facebook/python-sdk
•   Designed to support Graph API and FB
    Javascript SDK (You will learn in the future)




                                        f
                                             Introduction to
                                            Facebook PY API
Graph


•   Depends your access token
•   Everyone will have their own graph, could
    be unique




                                     f
                                          Introduction to
                                         Facebook PY API
Graph API Class
•   Fetch the graph by implement it


    import	
  facebook

    graph	
  =	
  facebook.GraphAPI()
    user	
  =	
  graph.get_object(“littleq0903”)




                                                   f
                                                        Introduction to
                                                       Facebook PY API
Authentication
       my_profile	
  =	
  graph.get_object(“me”)


•   Graph can be implemented with an access
    token

          graph	
  =	
  GraphAPI(ACCESS_TOKEN)



•   And the perspective of the graph will be
    different

                                                 f
                                                      Introduction to
                                                     Facebook PY API
Graph Methods

•   get_object, get_objects
•   get_connections
•   put_object
•   put_wall_post, put_comment, put_like
•   delete_object


                                    f
                                         Introduction to
                                        Facebook PY API
Demo



       f
            Introduction to
           Facebook PY API
Homework

•   Fetch a kind of data on the FB Graph
•   Do some statistics on it
•   Don’t Copy from others




                                      f
                                            Introduction to
                                           Facebook PY API
Q&A Time
Thanks for your listening



                            f
                                 Introduction to
                                Facebook PY API

More Related Content

PDF
Introduction to Facebook Python API
PDF
Introduction to Facebook Javascript SDK (NEW)
PDF
[Code Camp] Ứng dụng Facebook API vào phát triển website
PDF
Interactive with-facebook
PDF
Facebook Open Stream API - Facebook Developer Garage Dhaka
PDF
Php day 2011 - Interactive-with-facebook
PDF
Facebook API for Developers : Introducing the Facebook Platform
PPTX
Alphageeks meetup - facebook api
Introduction to Facebook Python API
Introduction to Facebook Javascript SDK (NEW)
[Code Camp] Ứng dụng Facebook API vào phát triển website
Interactive with-facebook
Facebook Open Stream API - Facebook Developer Garage Dhaka
Php day 2011 - Interactive-with-facebook
Facebook API for Developers : Introducing the Facebook Platform
Alphageeks meetup - facebook api

What's hot (12)

PPT
Facebook api
PDF
Facebook API for iOS
PPT
Facebook Connect
KEY
OAuth Introduction
PPTX
Download PowerPoint Project on social programming for engineering students
PPT
Facebook Connect Integration
PPT
Creating a Facebook App
DOC
A Guide Social Media Platforms
PDF
Web 2 0 Search Engine Optimization Manual
PDF
Pr7 8 clubwear-and-party-wear
PDF
Facebook Dorkbot
PDF
New Media Tools In The Newsroom A Beginners Guide 12
Facebook api
Facebook API for iOS
Facebook Connect
OAuth Introduction
Download PowerPoint Project on social programming for engineering students
Facebook Connect Integration
Creating a Facebook App
A Guide Social Media Platforms
Web 2 0 Search Engine Optimization Manual
Pr7 8 clubwear-and-party-wear
Facebook Dorkbot
New Media Tools In The Newsroom A Beginners Guide 12
Ad

Viewers also liked (20)

PPTX
Python at Facebook
PDF
Introduction to Facebook JavaScript & Python SDK
PDF
Super Sizing Youtube with Python
PPT
Top 10 Scalability Mistakes
KEY
Facebook Development for Beginners
PPTX
RDS_Photoscan_Eval_Cloud
PPTX
Python games
PPT
Introduction To Facebook: Opportunities and Challenges For The Institution
PPTX
introduction to server-side scripting
PDF
Why APIs? Why API Management? Michel dorochevsky - Introduction-API-Managemet
PPTX
Server and Client side comparision
PDF
Workshop : Facebook JavaScript SDK
PDF
Introduction to Game programming with PyGame Part 1
PDF
Website vs web app
PPTX
Facebook ist tot. Eine Obduktion in sieben Akten. @ AllFacebook Marketing Con...
PDF
An Introduction to the WSO2 API Manager
PPTX
API designing with WSO2 API Manager
PPTX
API-Industrie
KEY
Mobile app Vs Web App
PDF
WSO2 API Manager 2.0 - Overview
Python at Facebook
Introduction to Facebook JavaScript & Python SDK
Super Sizing Youtube with Python
Top 10 Scalability Mistakes
Facebook Development for Beginners
RDS_Photoscan_Eval_Cloud
Python games
Introduction To Facebook: Opportunities and Challenges For The Institution
introduction to server-side scripting
Why APIs? Why API Management? Michel dorochevsky - Introduction-API-Managemet
Server and Client side comparision
Workshop : Facebook JavaScript SDK
Introduction to Game programming with PyGame Part 1
Website vs web app
Facebook ist tot. Eine Obduktion in sieben Akten. @ AllFacebook Marketing Con...
An Introduction to the WSO2 API Manager
API designing with WSO2 API Manager
API-Industrie
Mobile app Vs Web App
WSO2 API Manager 2.0 - Overview
Ad

Similar to Facebook Python SDK - Introduction (6)

PDF
Facebook api for iOS
PPTX
Facebook Open Graph Protocol and Graph API (NoVA Code Camp 2010.1)
KEY
20110611 Facebook Case Study
PPTX
20140505 - Victor Gau - R to access the social graph from facebook
PPTX
An introduction to mixi Graph API
KEY
MTSW-Facebook-1
Facebook api for iOS
Facebook Open Graph Protocol and Graph API (NoVA Code Camp 2010.1)
20110611 Facebook Case Study
20140505 - Victor Gau - R to access the social graph from facebook
An introduction to mixi Graph API
MTSW-Facebook-1

More from Colin Su (20)

PDF
Introduction to Google Compute Engine
PDF
Introduction to Google Cloud Endpoints: Speed Up Your API Development
PDF
Functional programming in Python
PDF
Web2py Code Lab
PDF
A Tour of Google Cloud Platform
PDF
Introduction to MapReduce & hadoop
PDF
Introduction to Google App Engine
PDF
Django Deployer
PDF
Introduction to Google - the most natural way to learn English (English Speech)
PDF
How to Speak Charms Like a Wizard
PDF
房地產報告
PDF
Introduction to Git
PDF
Web Programming - 1st TA Session
PDF
Nested List Comprehension and Binary Search
PDF
Python-List comprehension
PDF
Python-FileIO
KEY
Python Dictionary
PDF
Vim editor
PDF
VPython introduction
PDF
Linux-Permission
Introduction to Google Compute Engine
Introduction to Google Cloud Endpoints: Speed Up Your API Development
Functional programming in Python
Web2py Code Lab
A Tour of Google Cloud Platform
Introduction to MapReduce & hadoop
Introduction to Google App Engine
Django Deployer
Introduction to Google - the most natural way to learn English (English Speech)
How to Speak Charms Like a Wizard
房地產報告
Introduction to Git
Web Programming - 1st TA Session
Nested List Comprehension and Binary Search
Python-List comprehension
Python-FileIO
Python Dictionary
Vim editor
VPython introduction
Linux-Permission

Recently uploaded (20)

PDF
5-Ways-AI-is-Revolutionizing-Telecom-Quality-Engineering.pdf
PDF
A symptom-driven medical diagnosis support model based on machine learning te...
PDF
4 layer Arch & Reference Arch of IoT.pdf
PDF
NewMind AI Weekly Chronicles – August ’25 Week IV
PDF
Data Virtualization in Action: Scaling APIs and Apps with FME
PDF
substrate PowerPoint Presentation basic one
PDF
Accessing-Finance-in-Jordan-MENA 2024 2025.pdf
PDF
“The Future of Visual AI: Efficient Multimodal Intelligence,” a Keynote Prese...
PPTX
Presentation - Principles of Instructional Design.pptx
PDF
Co-training pseudo-labeling for text classification with support vector machi...
PDF
CXOs-Are-you-still-doing-manual-DevOps-in-the-age-of-AI.pdf
PDF
Planning-an-Audit-A-How-To-Guide-Checklist-WP.pdf
PDF
ment.tech-Siri Delay Opens AI Startup Opportunity in 2025.pdf
PDF
Aug23rd - Mulesoft Community Workshop - Hyd, India.pdf
PDF
Build Real-Time ML Apps with Python, Feast & NoSQL
PDF
giants, standing on the shoulders of - by Daniel Stenberg
PDF
Transform-Your-Streaming-Platform-with-AI-Driven-Quality-Engineering.pdf
DOCX
Basics of Cloud Computing - Cloud Ecosystem
PDF
Introduction to MCP and A2A Protocols: Enabling Agent Communication
PDF
SaaS reusability assessment using machine learning techniques
5-Ways-AI-is-Revolutionizing-Telecom-Quality-Engineering.pdf
A symptom-driven medical diagnosis support model based on machine learning te...
4 layer Arch & Reference Arch of IoT.pdf
NewMind AI Weekly Chronicles – August ’25 Week IV
Data Virtualization in Action: Scaling APIs and Apps with FME
substrate PowerPoint Presentation basic one
Accessing-Finance-in-Jordan-MENA 2024 2025.pdf
“The Future of Visual AI: Efficient Multimodal Intelligence,” a Keynote Prese...
Presentation - Principles of Instructional Design.pptx
Co-training pseudo-labeling for text classification with support vector machi...
CXOs-Are-you-still-doing-manual-DevOps-in-the-age-of-AI.pdf
Planning-an-Audit-A-How-To-Guide-Checklist-WP.pdf
ment.tech-Siri Delay Opens AI Startup Opportunity in 2025.pdf
Aug23rd - Mulesoft Community Workshop - Hyd, India.pdf
Build Real-Time ML Apps with Python, Feast & NoSQL
giants, standing on the shoulders of - by Daniel Stenberg
Transform-Your-Streaming-Platform-with-AI-Driven-Quality-Engineering.pdf
Basics of Cloud Computing - Cloud Ecosystem
Introduction to MCP and A2A Protocols: Enabling Agent Communication
SaaS reusability assessment using machine learning techniques

Facebook Python SDK - Introduction

  • 1. Introduction to Facebook Python API Social Network and Applications, 2011 LittleQ, The Department of Computer Science, NCCU f Introduction to Facebook PY API
  • 2. Objectives • Learn the concepts of Facebook API • Learn how to play with Facebook Graph API f Introduction to Facebook PY API
  • 3. Core Topics • Facebook Developers website • Graph API • Facebook Python SDK • Resources f Introduction to Facebook PY API
  • 4. Facebook Developers • Provide you online documentations • Forum for discussion • Management of your applications f Introduction to Facebook PY API
  • 5. Where is it? f Introduction to Facebook PY API
  • 6. Social Plugins • Like Button, Send Button, Login Button • Comments • Your Friends • Activity Feed, Live Stream f Introduction to Facebook PY API
  • 7. Is That What You Want? f Introduction to Facebook PY API
  • 8. Graph API Response Data Aggregate Information Access Token Request Data Application Graph API Facebook Database • Facebook’s core • Social graph • Connections f Introduction to Facebook PY API
  • 9. Graph Model • Composed of objects and connections • Identify entities and relationships by id • Data will be stored with smallest spaces and keep being updated f Introduction to Facebook PY API
  • 10. Object Model information from graph API without access token f Introduction to Facebook PY API
  • 11. Graph Model information from graph API with access token f Introduction to Facebook PY API
  • 12. Connection Model • All of the object in the Facebook social graph are connected to each other via connections • Objects are just like entities while connections are like relationship • For example, users, pages and groups are objects and likes, friends and feeds are connections f Introduction to Facebook PY API
  • 13. Connection Model f Introduction to Facebook PY API
  • 14. Access to Graph • HTTP(S) Graph API • SDKs ‣ Javascript SDK ‣ iOS SDK ‣ Android SDK ‣ PHP SDK ‣ Python SDK f Introduction to Facebook PY API
  • 15. HTTP(S) Graph API • RESTful HTTP request & response • Response data-type: JSON • Access URL: graph.facebook.com f Introduction to Facebook PY API
  • 16. HTTP(S) Graph API http://graph.facebook.com/<id-­‐or-­‐username> • Request information of an object with id or username • id-or-username can be “me” with the access token f Introduction to Facebook PY API
  • 17. HTTP(S) Graph API http://graph.facebook.com/littleq0903 Result: {      "id":  "1681390745",      "name":  "Colin  Su",      "first_name":  "Colin",      "last_name":  "Su",      "link":  "https://www.facebook.com/littleq0903",      "username":  "littleq0903",      "gender":  "male",      "locale":  "en_US" } f Introduction to Facebook PY API
  • 18. Access Token • A long string stands for the authentication of users • Temporary • The information behind the access token ‣ user id ‣ app id ‣ expired time ‣ secret f Introduction to Facebook PY API
  • 19. Get Access Token • GetMyAccess http://getmyaccess.heroku.com • It requires a permission called “offline_access”, so this token can be valid for a long time f Introduction to Facebook PY API
  • 20. HTTP(S) Graph API • Access token should be transferred as a HTTP GET variable http://graph.facebook.com/littleq0903?access_token=... • More information: developers.facebook.com/docs/reference/ api/ f Introduction to Facebook PY API
  • 21. Python SDK • Let you access all features of the Graph API • That’s all, let’s play! f Introduction to Facebook PY API
  • 22. Python SDK • https://github.com/facebook/python-sdk • Designed to support Graph API and FB Javascript SDK (You will learn in the future) f Introduction to Facebook PY API
  • 23. Graph • Depends your access token • Everyone will have their own graph, could be unique f Introduction to Facebook PY API
  • 24. Graph API Class • Fetch the graph by implement it import  facebook graph  =  facebook.GraphAPI() user  =  graph.get_object(“littleq0903”) f Introduction to Facebook PY API
  • 25. Authentication my_profile  =  graph.get_object(“me”) • Graph can be implemented with an access token graph  =  GraphAPI(ACCESS_TOKEN) • And the perspective of the graph will be different f Introduction to Facebook PY API
  • 26. Graph Methods • get_object, get_objects • get_connections • put_object • put_wall_post, put_comment, put_like • delete_object f Introduction to Facebook PY API
  • 27. Demo f Introduction to Facebook PY API
  • 28. Homework • Fetch a kind of data on the FB Graph • Do some statistics on it • Don’t Copy from others f Introduction to Facebook PY API
  • 29. Q&A Time Thanks for your listening f Introduction to Facebook PY API