SlideShare ist ein Scribd-Unternehmen logo
1 von 19
Downloaden Sie, um offline zu lesen
API
Introduction to Facebook Javascript API
Social Network and Applications, 2011
LittleQ, The Department of Computer Science, NCCU




                                                    f   Introduction to
                                                        Facebook JS API
Requirement

• HTML
• Basic Javascript
• Graph API
• Optional: AJAX, jQuery, CSS...

                                   f   Introduction to
                                       Facebook JS API
Javascript SDK
• Let you access all features of the Graph
  API or dialogs via Javascript
• Authentication
• Rendering the XFBML versions of
  Social Plugins
• Most functions in the FB Javascript
  SDK require an app id


                                  f     Introduction to
                                        Facebook JS API
Load the Script
• You must specify a <div> element with
  id “fb-root” in your web pages
           <div	
  id=”fb-­‐root”></div>

• The location of the script
 http://connect.facebook.net/	
  	
  	
  	
  	
  /all.js
                             zh_TW
                             en_US




                                                 f   Introduction to
                                                     Facebook JS API
Initialization
    FB.init({
    	
  	
  	
  	
  appId	
  	
  :	
  'YOUR	
  APP	
  ID',
    	
  	
  	
  	
  status	
  :	
  true,	
  //	
  check	
  login	
  status
    	
  	
  	
  	
  cookie	
  :	
  true,	
  //	
  enable	
  cookies
    	
  	
  	
  	
  xfbml	
  	
  :	
  true	
  	
  //	
  parse	
  XFBML
    	
  	
  });




• Do this after the “fb-root” div element
  has been built


                                                                             f   Introduction to
                                                                                 Facebook JS API
Components

• Core Methods
• Event Handling
• XFBML Methods
• Data Access Utilities
• Canvas Methods

                          f   Introduction to
                              Facebook JS API
Core Methods
•   FB.api(): Access the Graph API

•   FB.getLoginStatus()

•   FB.getSession()

•   FB.init(): Method of initialization

•   FB.login(): Login method

•   FB.logout(): Logout method

•   FB.ui(): Method to call dialogs


                                          f   Introduction to
                                              Facebook JS API
FB.api()
• make a API call to the Graph API
• depending on the connect status and
  the permissions
                                 Call if success.
     function	
  SuccessCall(res){
        alert(res.name);
     }


     FB.api('/me',	
  SuccessCall);


                                      f   Introduction to
                                          Facebook JS API
Example - Get Profile
          FB.api(“/me”	
  ,	
  function(response){
              console.log(response.data);
          }


response.data	
  =>	
  {
     email:	
  "littleq0903@gmail.com",
     first_name:	
  "Colin",
     gender:	
  "male",
     id:	
  "1681390745",
     last_name:	
  "Su",
     link:	
  "https://www.facebook.com/littleq0903",
     locale:	
  "en_US",
     name:	
  "Colin	
  Su",
     timezone:	
  8,
     updated_time:	
  "2011-­‐12-­‐16T09:43:06+0000",
     username:	
  "littleq0903",
     verified:	
  true



                                                        f
}
                                                            Introduction to
                                                            Facebook JS API
Example - Get Friends
       FB.api(“/me/friends”	
  ,	
  function(response){
           console.log(response.data);
       }



        response.data	
  =>	
  [
          {	
  id:	
  4	
  ,	
  name:	
  “Mark	
  Zurgberg”},
          {	
  id:	
  123	
  ,	
  name:	
  “Spiderman”	
  },
          {	
  id:	
  49973	
  ,	
  name:	
  “Steve	
  Jobs”	
  },
          {	
  id:	
  55688	
  ,	
  name:	
  “Taiwan	
  Taxi”	
  },
          ...
        ]



response will be an array with your friends data


                                                                      f   Introduction to
                                                                          Facebook JS API
Example - Get Posts
 FB.api(“/me/feed”	
  ,	
  {	
  limit:	
  10	
  }	
  ,
    function(response){
      console.log(response.data);
    }
 );




Check the response.data by yourself!




                                                         f   Introduction to
                                                             Facebook JS API
Example - Send Post
FB.api(“/me/feed”	
  ,	
  
    “post”	
  ,	
  
    {	
  message:	
  “Hello	
  World”	
  }	
  ,
    function	
  (response)	
  {	
  
           if(!response	
  ||	
  response.error)	
  {
                  alert(“error”);
           }	
  else	
  {
                  //success,	
  and	
  then	
  refresh	
  feed
           }
    }
);




                                                                 f   Introduction to
                                                                     Facebook JS API
FB.ui()
FB.ui(
	
  	
  	
  {
	
  	
  	
  	
  	
  method:	
  'feed',
	
  	
  	
  	
  	
  name:	
  'Facebook	
  Dialogs',
	
  	
  	
  	
  	
  link:	
  'https://developers.facebook.com/docs/reference/dialogs/',
	
  	
  	
  	
  	
  picture:	
  'http://fbrell.com/f8.jpg',
	
  	
  	
  	
  	
  caption:	
  'Reference	
  Documentation',
	
  	
  	
  	
  	
  description:	
  'Dialogs	
  provide	
  a	
  simple,	
  consistent	
  interface	
  for	
  
applications	
  to	
  interface	
  with	
  users.',
	
  	
  	
  	
  	
  message:	
  'Facebook	
  Dialogs	
  are	
  easy!'
	
  	
  	
  }
	
  );



        • Triggering iframe dialogs or popups with
             Facebook

                                                                                        f     Introduction to
                                                                                              Facebook JS API
More Topics

• Event Handling
• XFBML
• FQL
• Other SDKs for Facebook Graph API

                               f   Introduction to
                                   Facebook JS API
Tools

• Javascript Console
• Debug version of Facebook JS SDK
• Test users
• URL Linter

                              f   Introduction to
                                  Facebook JS API
Examples

• js_new_ex.html - template file
• js_new_ex1.html - Get Friend List
• js_new_ex2.html - Custom Feed
• js_new_ex3.html - Using Dialog
• Download URL: http://goo.gl/3Fwml

                                f   Introduction to
                                    Facebook JS API
Temporary HTTP Server

 • python	
  -­‐m	
  SimpleHTTPServer	
  5000

 • http://127.0.0.1:5000/
 • Facebook app allow only one domain
   access at a time




                                      f   Introduction to
                                          Facebook JS API
Resources
[1] Facebook Developers -
developers.facebook.com/docs/reference/
javascript/
[2] jQuery - jquery.com
[3] Javascript tutorial - www.study-area.org/coobila/
category_Javascript_u6559_u5B78.html
[4] Google - www.google.com

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



                            f   Introduction to
                                Facebook JS API

Weitere ähnliche Inhalte

Was ist angesagt?

Facebook api
Facebook api Facebook api
Facebook api snipermkd
 
Download PowerPoint Project on social programming for engineering students
Download PowerPoint Project on social programming for engineering studentsDownload PowerPoint Project on social programming for engineering students
Download PowerPoint Project on social programming for engineering studentsSkyingBlogger
 
Facebook Connect Integration
Facebook Connect IntegrationFacebook Connect Integration
Facebook Connect Integrationmujahidslideshare
 
Facebook Open Graph Tech Requirements
Facebook Open Graph Tech RequirementsFacebook Open Graph Tech Requirements
Facebook Open Graph Tech RequirementsAffinitive
 
[Code Camp] Ứng dụng Facebook API vào phát triển website
[Code Camp] Ứng dụng Facebook API vào phát triển website[Code Camp] Ứng dụng Facebook API vào phát triển website
[Code Camp] Ứng dụng Facebook API vào phát triển websiteSieu Web
 
Leveraging Rails to Build Facebook Apps
Leveraging Rails to Build Facebook AppsLeveraging Rails to Build Facebook Apps
Leveraging Rails to Build Facebook AppsDavid Keener
 
Interactive with-facebook
Interactive with-facebookInteractive with-facebook
Interactive with-facebookTien Nguyen
 
OAuth Introduction
OAuth IntroductionOAuth Introduction
OAuth Introductionh_marvin
 
The Flash Facebook Cookbook - FlashMidlands
The Flash Facebook Cookbook - FlashMidlandsThe Flash Facebook Cookbook - FlashMidlands
The Flash Facebook Cookbook - FlashMidlandsJames Ford
 
Php day 2011 - Interactive-with-facebook
Php day 2011 - Interactive-with-facebookPhp day 2011 - Interactive-with-facebook
Php day 2011 - Interactive-with-facebookQuang Anh Le
 
Facebook Developer Garage Cyberjaya
Facebook Developer Garage CyberjayaFacebook Developer Garage Cyberjaya
Facebook Developer Garage CyberjayaMehedi Hasan Sumon
 
Introduction to Social Networking Sites and websites
Introduction to Social Networking Sites and websitesIntroduction to Social Networking Sites and websites
Introduction to Social Networking Sites and websitesShruti Arya
 
Building Facebook Apps
Building Facebook AppsBuilding Facebook Apps
Building Facebook AppsDavid Keener
 
An Introduction To The Use Of Widgets in libraries
An Introduction To The Use Of Widgets in librariesAn Introduction To The Use Of Widgets in libraries
An Introduction To The Use Of Widgets in librariesAaron Tay
 
Access Management Technologies Update by Simon McLeish and John Paschoud
Access Management Technologies Update by Simon McLeish and John PaschoudAccess Management Technologies Update by Simon McLeish and John Paschoud
Access Management Technologies Update by Simon McLeish and John PaschoudJISC.AM
 
Off Page SEO Strategies
Off Page SEO StrategiesOff Page SEO Strategies
Off Page SEO StrategiesShimanto Arif
 
Web 2.0: What Can It Offer The Research Community?
Web 2.0: What Can It Offer The Research Community?Web 2.0: What Can It Offer The Research Community?
Web 2.0: What Can It Offer The Research Community?lisbk
 

Was ist angesagt? (20)

Facebook api
Facebook api Facebook api
Facebook api
 
Download PowerPoint Project on social programming for engineering students
Download PowerPoint Project on social programming for engineering studentsDownload PowerPoint Project on social programming for engineering students
Download PowerPoint Project on social programming for engineering students
 
Facebook Connect
Facebook ConnectFacebook Connect
Facebook Connect
 
Facebook Connect Integration
Facebook Connect IntegrationFacebook Connect Integration
Facebook Connect Integration
 
Facebook Open Graph Tech Requirements
Facebook Open Graph Tech RequirementsFacebook Open Graph Tech Requirements
Facebook Open Graph Tech Requirements
 
[Code Camp] Ứng dụng Facebook API vào phát triển website
[Code Camp] Ứng dụng Facebook API vào phát triển website[Code Camp] Ứng dụng Facebook API vào phát triển website
[Code Camp] Ứng dụng Facebook API vào phát triển website
 
Leveraging Rails to Build Facebook Apps
Leveraging Rails to Build Facebook AppsLeveraging Rails to Build Facebook Apps
Leveraging Rails to Build Facebook Apps
 
Interactive with-facebook
Interactive with-facebookInteractive with-facebook
Interactive with-facebook
 
OAuth Introduction
OAuth IntroductionOAuth Introduction
OAuth Introduction
 
The Flash Facebook Cookbook - FlashMidlands
The Flash Facebook Cookbook - FlashMidlandsThe Flash Facebook Cookbook - FlashMidlands
The Flash Facebook Cookbook - FlashMidlands
 
Php day 2011 - Interactive-with-facebook
Php day 2011 - Interactive-with-facebookPhp day 2011 - Interactive-with-facebook
Php day 2011 - Interactive-with-facebook
 
Facebook Developer Garage Cyberjaya
Facebook Developer Garage CyberjayaFacebook Developer Garage Cyberjaya
Facebook Developer Garage Cyberjaya
 
Introduction to Social Networking Sites and websites
Introduction to Social Networking Sites and websitesIntroduction to Social Networking Sites and websites
Introduction to Social Networking Sites and websites
 
Hi5 Open Social
Hi5   Open SocialHi5   Open Social
Hi5 Open Social
 
Building Facebook Apps
Building Facebook AppsBuilding Facebook Apps
Building Facebook Apps
 
An Introduction To The Use Of Widgets in libraries
An Introduction To The Use Of Widgets in librariesAn Introduction To The Use Of Widgets in libraries
An Introduction To The Use Of Widgets in libraries
 
Access Management Technologies Update by Simon McLeish and John Paschoud
Access Management Technologies Update by Simon McLeish and John PaschoudAccess Management Technologies Update by Simon McLeish and John Paschoud
Access Management Technologies Update by Simon McLeish and John Paschoud
 
Facebook Coin
Facebook CoinFacebook Coin
Facebook Coin
 
Off Page SEO Strategies
Off Page SEO StrategiesOff Page SEO Strategies
Off Page SEO Strategies
 
Web 2.0: What Can It Offer The Research Community?
Web 2.0: What Can It Offer The Research Community?Web 2.0: What Can It Offer The Research Community?
Web 2.0: What Can It Offer The Research Community?
 

Andere mochten auch

Open tok Android sdk - Droidcon
Open tok Android sdk - DroidconOpen tok Android sdk - Droidcon
Open tok Android sdk - DroidconDroidcon Spain
 
Happy facebook developer
Happy facebook developerHappy facebook developer
Happy facebook developerYu-Wei Chuang
 
Making Facebook Faster
Making Facebook FasterMaking Facebook Faster
Making Facebook Fasterguest1240e7c
 
Facebook Platform for Developers
Facebook Platform for DevelopersFacebook Platform for Developers
Facebook Platform for DevelopersLidan Hifi
 
Facebook App Development
Facebook App DevelopmentFacebook App Development
Facebook App DevelopmentCristiano Betta
 
Facebook Development with Zend Framework
Facebook Development with Zend FrameworkFacebook Development with Zend Framework
Facebook Development with Zend FrameworkBrett Harris
 
Getting started with Facebook OpenGraph API
Getting started with Facebook OpenGraph APIGetting started with Facebook OpenGraph API
Getting started with Facebook OpenGraph APILynn Langit
 
Facebook Open Graph API and How To Use It
Facebook Open Graph API and How To Use ItFacebook Open Graph API and How To Use It
Facebook Open Graph API and How To Use ItAayush Shrestha
 
Facebook Open Graph API
Facebook Open Graph APIFacebook Open Graph API
Facebook Open Graph APIColin Smillie
 
Introduction to Google Compute Engine
Introduction to Google Compute EngineIntroduction to Google Compute Engine
Introduction to Google Compute EngineColin Su
 

Andere mochten auch (11)

Open tok Android sdk - Droidcon
Open tok Android sdk - DroidconOpen tok Android sdk - Droidcon
Open tok Android sdk - Droidcon
 
Happy facebook developer
Happy facebook developerHappy facebook developer
Happy facebook developer
 
Making Facebook Faster
Making Facebook FasterMaking Facebook Faster
Making Facebook Faster
 
Facebook Platform for Developers
Facebook Platform for DevelopersFacebook Platform for Developers
Facebook Platform for Developers
 
Facebook App Development
Facebook App DevelopmentFacebook App Development
Facebook App Development
 
Facebook Development with Zend Framework
Facebook Development with Zend FrameworkFacebook Development with Zend Framework
Facebook Development with Zend Framework
 
Getting started with Facebook OpenGraph API
Getting started with Facebook OpenGraph APIGetting started with Facebook OpenGraph API
Getting started with Facebook OpenGraph API
 
Facebook Open Graph API and How To Use It
Facebook Open Graph API and How To Use ItFacebook Open Graph API and How To Use It
Facebook Open Graph API and How To Use It
 
Facebook Open Graph API
Facebook Open Graph APIFacebook Open Graph API
Facebook Open Graph API
 
Introduction to Google Compute Engine
Introduction to Google Compute EngineIntroduction to Google Compute Engine
Introduction to Google Compute Engine
 
Facebook + Ruby
Facebook + RubyFacebook + Ruby
Facebook + Ruby
 

Ähnlich wie Introduction to Facebook Javascript SDK (NEW)

페이스북 소셜 앱 개발 가이드 2011
페이스북 소셜 앱 개발 가이드 2011페이스북 소셜 앱 개발 가이드 2011
페이스북 소셜 앱 개발 가이드 2011Sukjoon Kim
 
Alphageeks meetup - facebook api
Alphageeks meetup - facebook apiAlphageeks meetup - facebook api
Alphageeks meetup - facebook apiAlphageeks
 
Facebook API
Facebook APIFacebook API
Facebook APIsnipermkd
 
Developing Facebook Application - Nagpur PHP Meetup
Developing Facebook Application - Nagpur PHP MeetupDeveloping Facebook Application - Nagpur PHP Meetup
Developing Facebook Application - Nagpur PHP MeetupAbhishek Deshpande
 
Peepcode facebook-2-rails on facebook
Peepcode facebook-2-rails on facebookPeepcode facebook-2-rails on facebook
Peepcode facebook-2-rails on facebooksushilprajapati
 
Facebook Apps: Ein Entwicklungsleitfaden - WMMRN
Facebook Apps: Ein Entwicklungsleitfaden - WMMRNFacebook Apps: Ein Entwicklungsleitfaden - WMMRN
Facebook Apps: Ein Entwicklungsleitfaden - WMMRNStephan Hochdörfer
 
Google App Engine and Social Apps
Google App Engine and Social AppsGoogle App Engine and Social Apps
Google App Engine and Social AppsChris Schalk
 
Facebook 3rd Party Api
Facebook 3rd Party ApiFacebook 3rd Party Api
Facebook 3rd Party ApiYoss Cohen
 
Facebook Development in 5 Minutes
Facebook Development in 5 MinutesFacebook Development in 5 Minutes
Facebook Development in 5 MinutesJesse Stay
 
Facebook api além de meros usuários
Facebook api além de meros usuáriosFacebook api além de meros usuários
Facebook api além de meros usuáriosAécio Costa
 
Facebook plateform architecture presentation
Facebook plateform architecture   presentationFacebook plateform architecture   presentation
Facebook plateform architecture presentationInam Soomro
 
Building an interactive timeline from facebook photos
Building an interactive timeline from facebook photosBuilding an interactive timeline from facebook photos
Building an interactive timeline from facebook photosRakesh Rajan
 
Introduction to facebook platform
Introduction to facebook platformIntroduction to facebook platform
Introduction to facebook platformVenkatesh Narayanan
 
Facebook Connect Presentation 08 10 2008
Facebook Connect Presentation 08 10 2008Facebook Connect Presentation 08 10 2008
Facebook Connect Presentation 08 10 2008Karl Bunyan
 
funP 麻吉 開發者俱樂部十月份聚會
funP 麻吉 開發者俱樂部十月份聚會funP 麻吉 開發者俱樂部十月份聚會
funP 麻吉 開發者俱樂部十月份聚會Nathan Chiu
 
Facebook Open Stream API - Facebook Developer Garage Dhaka
Facebook Open Stream API - Facebook Developer Garage DhakaFacebook Open Stream API - Facebook Developer Garage Dhaka
Facebook Open Stream API - Facebook Developer Garage DhakaMohammad Emran Hasan
 

Ähnlich wie Introduction to Facebook Javascript SDK (NEW) (20)

Graph api
Graph apiGraph api
Graph api
 
Creating a Facebook App
Creating a Facebook AppCreating a Facebook App
Creating a Facebook App
 
페이스북 소셜 앱 개발 가이드 2011
페이스북 소셜 앱 개발 가이드 2011페이스북 소셜 앱 개발 가이드 2011
페이스북 소셜 앱 개발 가이드 2011
 
Alphageeks meetup - facebook api
Alphageeks meetup - facebook apiAlphageeks meetup - facebook api
Alphageeks meetup - facebook api
 
Facebook API
Facebook APIFacebook API
Facebook API
 
Developing Facebook Application - Nagpur PHP Meetup
Developing Facebook Application - Nagpur PHP MeetupDeveloping Facebook Application - Nagpur PHP Meetup
Developing Facebook Application - Nagpur PHP Meetup
 
Peepcode facebook-2-rails on facebook
Peepcode facebook-2-rails on facebookPeepcode facebook-2-rails on facebook
Peepcode facebook-2-rails on facebook
 
Facebook Apps: Ein Entwicklungsleitfaden - WMMRN
Facebook Apps: Ein Entwicklungsleitfaden - WMMRNFacebook Apps: Ein Entwicklungsleitfaden - WMMRN
Facebook Apps: Ein Entwicklungsleitfaden - WMMRN
 
Facebook api for iOS
Facebook api for iOSFacebook api for iOS
Facebook api for iOS
 
Google App Engine and Social Apps
Google App Engine and Social AppsGoogle App Engine and Social Apps
Google App Engine and Social Apps
 
Facebook 3rd Party Api
Facebook 3rd Party ApiFacebook 3rd Party Api
Facebook 3rd Party Api
 
Facebook Development in 5 Minutes
Facebook Development in 5 MinutesFacebook Development in 5 Minutes
Facebook Development in 5 Minutes
 
Developing Facebook Application
Developing Facebook ApplicationDeveloping Facebook Application
Developing Facebook Application
 
Facebook api além de meros usuários
Facebook api além de meros usuáriosFacebook api além de meros usuários
Facebook api além de meros usuários
 
Facebook plateform architecture presentation
Facebook plateform architecture   presentationFacebook plateform architecture   presentation
Facebook plateform architecture presentation
 
Building an interactive timeline from facebook photos
Building an interactive timeline from facebook photosBuilding an interactive timeline from facebook photos
Building an interactive timeline from facebook photos
 
Introduction to facebook platform
Introduction to facebook platformIntroduction to facebook platform
Introduction to facebook platform
 
Facebook Connect Presentation 08 10 2008
Facebook Connect Presentation 08 10 2008Facebook Connect Presentation 08 10 2008
Facebook Connect Presentation 08 10 2008
 
funP 麻吉 開發者俱樂部十月份聚會
funP 麻吉 開發者俱樂部十月份聚會funP 麻吉 開發者俱樂部十月份聚會
funP 麻吉 開發者俱樂部十月份聚會
 
Facebook Open Stream API - Facebook Developer Garage Dhaka
Facebook Open Stream API - Facebook Developer Garage DhakaFacebook Open Stream API - Facebook Developer Garage Dhaka
Facebook Open Stream API - Facebook Developer Garage Dhaka
 

Mehr von Colin Su

Introduction to Google Cloud Endpoints: Speed Up Your API Development
Introduction to Google Cloud Endpoints: Speed Up Your API DevelopmentIntroduction to Google Cloud Endpoints: Speed Up Your API Development
Introduction to Google Cloud Endpoints: Speed Up Your API DevelopmentColin Su
 
Functional programming in Python
Functional programming in PythonFunctional programming in Python
Functional programming in PythonColin Su
 
Web2py Code Lab
Web2py Code LabWeb2py Code Lab
Web2py Code LabColin Su
 
A Tour of Google Cloud Platform
A Tour of Google Cloud PlatformA Tour of Google Cloud Platform
A Tour of Google Cloud PlatformColin Su
 
Introduction to MapReduce & hadoop
Introduction to MapReduce & hadoopIntroduction to MapReduce & hadoop
Introduction to MapReduce & hadoopColin Su
 
Introduction to Google App Engine
Introduction to Google App EngineIntroduction to Google App Engine
Introduction to Google App EngineColin Su
 
Django Deployer
Django DeployerDjango Deployer
Django DeployerColin Su
 
Introduction to Google - the most natural way to learn English (English Speech)
Introduction to Google - the most natural way to learn English (English Speech)Introduction to Google - the most natural way to learn English (English Speech)
Introduction to Google - the most natural way to learn English (English Speech)Colin Su
 
How to Speak Charms Like a Wizard
How to Speak Charms Like a WizardHow to Speak Charms Like a Wizard
How to Speak Charms Like a WizardColin Su
 
房地產報告
房地產報告房地產報告
房地產報告Colin Su
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to GitColin Su
 
Introduction to Facebook Python API
Introduction to Facebook Python APIIntroduction to Facebook Python API
Introduction to Facebook Python APIColin Su
 
Web Programming - 1st TA Session
Web Programming - 1st TA SessionWeb Programming - 1st TA Session
Web Programming - 1st TA SessionColin Su
 
Nested List Comprehension and Binary Search
Nested List Comprehension and Binary SearchNested List Comprehension and Binary Search
Nested List Comprehension and Binary SearchColin Su
 
Python-List comprehension
Python-List comprehensionPython-List comprehension
Python-List comprehensionColin Su
 
Python-FileIO
Python-FileIOPython-FileIO
Python-FileIOColin Su
 
Python Dictionary
Python DictionaryPython Dictionary
Python DictionaryColin Su
 
Vim editor
Vim editorVim editor
Vim editorColin Su
 
VPython introduction
VPython introductionVPython introduction
VPython introductionColin Su
 
Linux-Permission
Linux-PermissionLinux-Permission
Linux-PermissionColin Su
 

Mehr von Colin Su (20)

Introduction to Google Cloud Endpoints: Speed Up Your API Development
Introduction to Google Cloud Endpoints: Speed Up Your API DevelopmentIntroduction to Google Cloud Endpoints: Speed Up Your API Development
Introduction to Google Cloud Endpoints: Speed Up Your API Development
 
Functional programming in Python
Functional programming in PythonFunctional programming in Python
Functional programming in Python
 
Web2py Code Lab
Web2py Code LabWeb2py Code Lab
Web2py Code Lab
 
A Tour of Google Cloud Platform
A Tour of Google Cloud PlatformA Tour of Google Cloud Platform
A Tour of Google Cloud Platform
 
Introduction to MapReduce & hadoop
Introduction to MapReduce & hadoopIntroduction to MapReduce & hadoop
Introduction to MapReduce & hadoop
 
Introduction to Google App Engine
Introduction to Google App EngineIntroduction to Google App Engine
Introduction to Google App Engine
 
Django Deployer
Django DeployerDjango Deployer
Django Deployer
 
Introduction to Google - the most natural way to learn English (English Speech)
Introduction to Google - the most natural way to learn English (English Speech)Introduction to Google - the most natural way to learn English (English Speech)
Introduction to Google - the most natural way to learn English (English Speech)
 
How to Speak Charms Like a Wizard
How to Speak Charms Like a WizardHow to Speak Charms Like a Wizard
How to Speak Charms Like a Wizard
 
房地產報告
房地產報告房地產報告
房地產報告
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to Git
 
Introduction to Facebook Python API
Introduction to Facebook Python APIIntroduction to Facebook Python API
Introduction to Facebook Python API
 
Web Programming - 1st TA Session
Web Programming - 1st TA SessionWeb Programming - 1st TA Session
Web Programming - 1st TA Session
 
Nested List Comprehension and Binary Search
Nested List Comprehension and Binary SearchNested List Comprehension and Binary Search
Nested List Comprehension and Binary Search
 
Python-List comprehension
Python-List comprehensionPython-List comprehension
Python-List comprehension
 
Python-FileIO
Python-FileIOPython-FileIO
Python-FileIO
 
Python Dictionary
Python DictionaryPython Dictionary
Python Dictionary
 
Vim editor
Vim editorVim editor
Vim editor
 
VPython introduction
VPython introductionVPython introduction
VPython introduction
 
Linux-Permission
Linux-PermissionLinux-Permission
Linux-Permission
 

Kürzlich hochgeladen

WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 

Kürzlich hochgeladen (20)

WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 

Introduction to Facebook Javascript SDK (NEW)

  • 1. API Introduction to Facebook Javascript API Social Network and Applications, 2011 LittleQ, The Department of Computer Science, NCCU f Introduction to Facebook JS API
  • 2. Requirement • HTML • Basic Javascript • Graph API • Optional: AJAX, jQuery, CSS... f Introduction to Facebook JS API
  • 3. Javascript SDK • Let you access all features of the Graph API or dialogs via Javascript • Authentication • Rendering the XFBML versions of Social Plugins • Most functions in the FB Javascript SDK require an app id f Introduction to Facebook JS API
  • 4. Load the Script • You must specify a <div> element with id “fb-root” in your web pages <div  id=”fb-­‐root”></div> • The location of the script http://connect.facebook.net/          /all.js zh_TW en_US f Introduction to Facebook JS API
  • 5. Initialization FB.init({        appId    :  'YOUR  APP  ID',        status  :  true,  //  check  login  status        cookie  :  true,  //  enable  cookies        xfbml    :  true    //  parse  XFBML    }); • Do this after the “fb-root” div element has been built f Introduction to Facebook JS API
  • 6. Components • Core Methods • Event Handling • XFBML Methods • Data Access Utilities • Canvas Methods f Introduction to Facebook JS API
  • 7. Core Methods • FB.api(): Access the Graph API • FB.getLoginStatus() • FB.getSession() • FB.init(): Method of initialization • FB.login(): Login method • FB.logout(): Logout method • FB.ui(): Method to call dialogs f Introduction to Facebook JS API
  • 8. FB.api() • make a API call to the Graph API • depending on the connect status and the permissions Call if success. function  SuccessCall(res){ alert(res.name); } FB.api('/me',  SuccessCall); f Introduction to Facebook JS API
  • 9. Example - Get Profile FB.api(“/me”  ,  function(response){ console.log(response.data); } response.data  =>  { email:  "littleq0903@gmail.com", first_name:  "Colin", gender:  "male", id:  "1681390745", last_name:  "Su", link:  "https://www.facebook.com/littleq0903", locale:  "en_US", name:  "Colin  Su", timezone:  8, updated_time:  "2011-­‐12-­‐16T09:43:06+0000", username:  "littleq0903", verified:  true f } Introduction to Facebook JS API
  • 10. Example - Get Friends FB.api(“/me/friends”  ,  function(response){ console.log(response.data); } response.data  =>  [ {  id:  4  ,  name:  “Mark  Zurgberg”}, {  id:  123  ,  name:  “Spiderman”  }, {  id:  49973  ,  name:  “Steve  Jobs”  }, {  id:  55688  ,  name:  “Taiwan  Taxi”  }, ... ] response will be an array with your friends data f Introduction to Facebook JS API
  • 11. Example - Get Posts FB.api(“/me/feed”  ,  {  limit:  10  }  , function(response){ console.log(response.data); } ); Check the response.data by yourself! f Introduction to Facebook JS API
  • 12. Example - Send Post FB.api(“/me/feed”  ,   “post”  ,   {  message:  “Hello  World”  }  , function  (response)  {   if(!response  ||  response.error)  { alert(“error”); }  else  { //success,  and  then  refresh  feed } } ); f Introduction to Facebook JS API
  • 13. FB.ui() FB.ui(      {          method:  'feed',          name:  'Facebook  Dialogs',          link:  'https://developers.facebook.com/docs/reference/dialogs/',          picture:  'http://fbrell.com/f8.jpg',          caption:  'Reference  Documentation',          description:  'Dialogs  provide  a  simple,  consistent  interface  for   applications  to  interface  with  users.',          message:  'Facebook  Dialogs  are  easy!'      }  ); • Triggering iframe dialogs or popups with Facebook f Introduction to Facebook JS API
  • 14. More Topics • Event Handling • XFBML • FQL • Other SDKs for Facebook Graph API f Introduction to Facebook JS API
  • 15. Tools • Javascript Console • Debug version of Facebook JS SDK • Test users • URL Linter f Introduction to Facebook JS API
  • 16. Examples • js_new_ex.html - template file • js_new_ex1.html - Get Friend List • js_new_ex2.html - Custom Feed • js_new_ex3.html - Using Dialog • Download URL: http://goo.gl/3Fwml f Introduction to Facebook JS API
  • 17. Temporary HTTP Server • python  -­‐m  SimpleHTTPServer  5000 • http://127.0.0.1:5000/ • Facebook app allow only one domain access at a time f Introduction to Facebook JS API
  • 18. Resources [1] Facebook Developers - developers.facebook.com/docs/reference/ javascript/ [2] jQuery - jquery.com [3] Javascript tutorial - www.study-area.org/coobila/ category_Javascript_u6559_u5B78.html [4] Google - www.google.com f Introduction to Facebook JS API
  • 19. Q&A Time Thanks for your listening f Introduction to Facebook JS API