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 Open Graph Tech Requirements
Facebook Open Graph Tech RequirementsFacebook Open Graph Tech Requirements
Facebook Open Graph Tech Requirements
Affinitive
 
OAuth Introduction
OAuth IntroductionOAuth Introduction
OAuth Introduction
h_marvin
 
The Flash Facebook Cookbook - FlashMidlands
The Flash Facebook Cookbook - FlashMidlandsThe Flash Facebook Cookbook - FlashMidlands
The Flash Facebook Cookbook - FlashMidlands
James Ford
 
Php day 2011 - Interactive-with-facebook
Php day 2011 - Interactive-with-facebookPhp day 2011 - Interactive-with-facebook
Php day 2011 - Interactive-with-facebook
Quang Anh Le
 

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

Introduction to Google Compute Engine
Introduction to Google Compute EngineIntroduction to Google Compute Engine
Introduction to Google Compute Engine
Colin 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)

Facebook API
Facebook APIFacebook API
Facebook API
snipermkd
 
Peepcode facebook-2-rails on facebook
Peepcode facebook-2-rails on facebookPeepcode facebook-2-rails on facebook
Peepcode facebook-2-rails on facebook
sushilprajapati
 
Facebook Apps: Ein Entwicklungsleitfaden - WMMRN
Facebook Apps: Ein Entwicklungsleitfaden - WMMRNFacebook Apps: Ein Entwicklungsleitfaden - WMMRN
Facebook Apps: Ein Entwicklungsleitfaden - WMMRN
Stephan Hochdörfer
 
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
Aécio Costa
 
Facebook plateform architecture presentation
Facebook plateform architecture   presentationFacebook plateform architecture   presentation
Facebook plateform architecture presentation
Inam Soomro
 
Introduction to facebook platform
Introduction to facebook platformIntroduction to facebook platform
Introduction to facebook platform
Venkatesh Narayanan
 
funP 麻吉 開發者俱樂部十月份聚會
funP 麻吉 開發者俱樂部十月份聚會funP 麻吉 開發者俱樂部十月份聚會
funP 麻吉 開發者俱樂部十月份聚會
Nathan Chiu
 

Ä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

Functional programming in Python
Functional programming in PythonFunctional programming in Python
Functional programming in Python
Colin Su
 
Web2py Code Lab
Web2py Code LabWeb2py Code Lab
Web2py Code Lab
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 Wizard
Colin Su
 
房地產報告
房地產報告房地產報告
房地產報告
Colin 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

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Kürzlich hochgeladen (20)

Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 

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