SlideShare a Scribd company logo
Me.

               James Ford
           http://www.psyked.co.uk/
                @psyked_james
      Product Development @ MMT Digital


      Web (HTML, CSS, JavaScript)
    Flash Platform (Flash, Flex, AIR)
 Mobile (Obj-C, ELIPS, Titanium, Corona SDK)
Flash Facebook Cookbook
             Published August 2011
             Packt Publishing

             - Facebook Graph API 1.6
             - FQL

             -     ,     &      ,

             - Introduction to Facebook
               Graph API, core concepts
               & lots of simple demo
               applications.
Initial questions


• What data is available from Facebook?
• How is that data structured?
• How do we connect to the Graph API?
• How do we locate information on Facebook?
• What data-access controls are in place?
Introducing
The Graph API
What is the Graph API?


• The API for accessing data held by Facebook
• Uses OAuth 2.0
• REST-style API
• JSON-encoded response objects
The Graph API is not:



• The Open Graph Protocol
• FQL (Facebook Query Language)
• Connect, FBML or Legacy REST API
Data available with
The Graph API
Data available from Facebook
Without Authentication (Access Tokens)
    • User ID, Combined name & Profile image
    • Any Publicly-accessible data: Users, Pages, Places, Groups & Events

With Authentication
    • Profile data: Name, Gender
    • Friend lists, Mutual friend information

With Authentication + Extended Permissions
    • Profile data: Birthday, Bio, Relationships, Religion, Politics...
                 (everything in your profile, basically)
    • News feeds, Profile feeds
    • Checkins, Notes, Photos, Videos
    • Comments, Likes
Data structures in
The Graph API
Facebook data types
Common types         And the less common...
  • Album               • Insights
  • Application         • Message
  • Checkin             • Note
  • Comment             • Question
  • Event               • QuestionOption
  • Group               • Review
  • Link                • Subscription
  • Page                • Thread
  • Photo
  • Post
  • Status message
  • User
  • Video
Graph API Objects
Everything has a unique Id, and can be accessed directly:

   • Users: https://graph.facebook.com/btaylor (Bret Taylor)
   • Pages: https://graph.facebook.com/cocacola (Coca-Cola page)
   • Events: https://graph.facebook.com/251906384206 (Facebook Developer Garage Austin)
   • Groups: https://graph.facebook.com/195466193802264 (Facebook Developers group)
   • Applications: https://graph.facebook.com/2439131959 (the Graffiti app)
   • Status messages: https://graph.facebook.com/367501354973 (A status message from Bret)
   • Photos: https://graph.facebook.com/98423808305 (A photo from the Coca-Cola page)
   • Photo albums: https://graph.facebook.com/99394368305 (Coca-Cola's wall photos)
   • Profile pictures: https://graph.facebook.com/psyked/picture (your profile picture)
   • Videos: https://graph.facebook.com/817129783203 (A Facebook tech talk on Graph API)
   • Notes: https://graph.facebook.com/122788341354 (Note announcing Facebook for iPhone 3.0)
   • Checkins: https://graph.facebook.com/414866888308 (Check-in at a pizzeria)
Graph API Connections
Graph API Connections are used to represent relationships in
the ‘social graph’, and return a JSON-encoded Array of objects.
   • Friends: https://graph.facebook.com/me/friends
   • News feed: https://graph.facebook.com/me/home
   • Profile feed (Wall): https://graph.facebook.com/me/feed
   • Likes: https://graph.facebook.com/me/likes
   • Books: https://graph.facebook.com/me/books
   • Permissions: https://graph.facebook.com/me/permissions
   • Photo Tags: https://graph.facebook.com/me/photos
   • Photo Albums: https://graph.facebook.com/me/albums
   • Video Tags: https://graph.facebook.com/me/videos
   • Video Uploads: https://graph.facebook.com/me/videos/uploaded
   • Events: https://graph.facebook.com/me/events
   • Groups: https://graph.facebook.com/me/groups
   • Checkins: https://graph.facebook.com/me/checkins
A Public Graph API Object
GET http://graph.facebook.com/platform

{
  "id": "19292868552",
  "name": "Facebook Platform",
  "picture": "http://profile.ak.fbcdn.net/hprofile-ak-
ash2/276791_19292868552_1958181823_s.jpg",
  "link": "https://www.facebook.com/platform",
  "likes": 3403793,
  "category": "Product/service",
  "website": "http://developers.facebook.com",
  "username": "platform",
  "founded": "2007",
  "company_overview": "Facebook Platform enables anyone to build social apps
on Facebook and the web.",
  "mission": "To make the web more open and social."
}
A Private Graph API Object
GET https://graph.facebook.com/me?access_token=AAAAAAITEgh...

{
    "id": "#########",
    "name": "James Ford",
    "first_name": "James",
    "last_name": "Ford",
    "link": "https://www.facebook.com/psyked",
    "username": "psyked",
    "birthday": "##/##/####",
    "hometown": {
       "id": "108126319208135",
       "name": "Stamford, Lincolnshire"
    },
    "gender": "male",
    "website": "http://www.psyked.co.uk",
    "locale": "en_GB",
    "verified": true,
    "updated_time": "2011-10-02T10:37:20+0000"
}
A Graph API Connection
GET https://graph.facebook.com/me/likes?access_token=AAAAA...
{
    "data": [
       {
          "name": "CodeBoxed",
          "category": "Computers/internet",
          "id": "126122064123731",
          "created_time": "2011-09-02T18:09:50+0000"
       },
       {
          "name": "The Grand Design",
          "category": "Book",
          "id": "153522094682666",
          "created_time": "2011-08-21T22:08:49+0000"
       },
       {
          "name": "on AIR Tour Europe 2008",
          "category": "Community",
          "id": "8295947366",
          "created_time": "2008-02-20T10:02:34+0000"
       }
    ]
}
Connecting to the
The Graph API
Client-side Data flow
Connecting to the Graph API
Retrieving data from
The Graph API
JavaScript & the Graph API
<div id="fb-root"></div>
<script src="http://connect.facebook.net/en_US/all.js"></script>
<script type="text/javascript">
  FB.init({ appId:'APP_ID' });

  FB.login(function(response) {
    if (response.session) {
      console.log('Welcome! Fetching your information.... ');
      FB.api('/me', function(response) {
        console.log('Good to see you, ' + response.name + '.');
      });
    } else {
      console.log('User cancelled login or did not fully
authorize.');
    }
  });
</script>
ActionScript & the Graph API
import com.facebook.graph.Facebook;

Facebook.init('API_KEY', responseHandler, { appId:'APP_ID' });

private function responseHandler( success:Object, fail:Object ):void {
  if (success) {
    Facebook.api('/platform', requestResponseHandler);
  } else {
    Facebook.login(loginResponseHandler);
  }
}

private function loginResponseHandler(success:Object, fail:Object):void {
  if (success) {
    Facebook.api('/platform', requestResponseHandler);
  } else {
    trace('Unable to log in');
  }
}

private function requestResponseHandler(success:Object, fail:Object):void {
  if (success) {
    trace(JSON.encode(success, true));
  }
}
What happens when I...
Don’t have access?
Requesting restricted data
Loading objects without an access token
 {
     "error": {
       "message": "An access token is required to request this resource.",
       "type": "OAuthException"
     }
 }



Loading objects without permissions
 {
     "error": {
       "message": "mailbox requires the read_mailbox extended permission.",
       "type": "OAuthException"
     }
 }
Working with
Extended Permissions
Extended Permissions
• Album: user_photos, friends_photos, publish_stream
• Checkin: user_checkins, friends_checkins, publish_stream
• Comment: publish_stream
• Event: user_event, friends_event, publish_stream
• Group: user_groups, friends_groups, publish_stream
• Insights: read_insights
• Link: read_stream, publish_stream
• Message: read_mailbox
• Notes: user_notes, friends_notes
• Page: manage_pages
• Photo: user_photos, friends_photos
• Post / Status message: read_stream, publish_stream
• User: user_about_me, friends_about_me, user_birthday, friends_birthday, user_education_history,
friends_education_history, email, user_hometown, friends_hometown, user_relationship_details,
friends_relationship_details, user_location, friends_location, user_religon_politics,
friends_religion_politics, user_likes, friends_likes, user_relationships, friends_relationships,
user_websites, friends_websites, user_work_history, friends_work_history
• Video: user_videos, friends_videos, publish_stream
Requesting Permissions
var options:Object = {};
options.perms = new Array("user_about_me", "email", "friends_birthday");
Facebook.login(loginResponseHandler, options);


private function loginResponseHandler(success:Object, fail:Object):void {
  if (success) {
    Facebook.api('/platform', requestResponseHandler);
  } else {
    trace('Unable to log in');
  }
}
Checking for Permissions
var missingPermissions:Array = new Array();

private function requestPermissionsInfo():void {
  var permissions:Array = new Array("read_stream", "publish_stream");
  Facebook.fqlQuery("SELECT {0} FROM permissions WHERE uid = me() ",
                    onFQLResponse, [permissions.toString()]);
}

private function onFQLResponse(success:Object, fail:Object):void {
                          [{
  missingPermissions = new Array();
                            "email":0,
  var results:Array = success as Array;
                            "publish_stream":1,
  if (success && results) { "read_stream":1
    for (var i:int = 0; i < results.length; i++) {
                          }]
      var queryResult:Object = results[i];
      for (var param:String in queryResult) {
        if (Boolean(queryResult[param]) == false) {
          missingPermissions.push(param);
        }
      }
    }
  }
}
Creating & Modifying
    Data on Facebook
Posting data to the Graph API

var options:Object = new Object();
options.name = "I found a trophy";
options.caption "100001986549853_202809986461885"}
        {"id": = "Gold trophy";
options.description = "I found a Gold trophy while using ...";
options.link = "http://apps.facebook.com/packt_facebook/";
options.picture = "http://facebook.psyked.co.uk/packt/images/gold.png";

Facebook.api("me/feed", responseHandler, options, "post");

private function responseHandler(success:Object, fail:Object):void {
    if (success) {
        trace(JSON.encode(success, true));
    } else {
        trace(JSON.encode(fail, true));
    }
}
Posting image data - webcam
import mx.graphics.ImageSnapshot;

var options:Object = {};
options.fileName = "webcam.png";
options.image = ImageSnapshot.captureBitmapData(webcam_display);
options.message = "Image caption";

Facebook.api("me/photos", photoUploadComplete, options, "post");
Posting image data - FileReference

var options:Object = {};
options.fileName = fr.name;
options.image = fr.data;
var fileExtension:String = fr.name.split(".")[fr.name.split(".").length-1];
switch (fileExtension) {
    case "gif":
        options.contentType = "image/gif";
        break;
    case "png":
        options.contentType = "image/png";
        break;
    case "jpeg":
    case "jpg":
        options.contentType = "image/jpeg";
        break;
}
options.message = "Image caption";

Facebook.api("me/photos", photoUploadComplete, options, "post");
Editing existing Objects
• Editing objects (that can be edited) is done by
var options:Object = new Object();
  making a POST request to an Objects’ URL.
options.name = "I found a trophy";
options.caption = "Gold trophy";
options.description = "I found a Gold trophy while using ...";
options.link = "http://apps.facebook.com/packt_facebook/";
options.picture = "http://facebook.psyked.co.uk/packt/images/gold.png";
        Application, Album, Event, Group and User
Facebook.api("me/feed", responseHandler, options, "post");
        objects have properties that can be edited.
private function responseHandler(success:Object, fail:Object):void {
    if (success) {
        trace(JSON.encode(success, true));
    } else {
        trace(JSON.encode(fail, true));
    }
}
Deleting existing Objects

var options:Object = new Object();
options.method = "delete";

Facebook.api("10150322337577749", responseHandler, options,
             "post");

private function responseHandler(success:Object,
                                 fail:Object):void {
    if (success) {
        trace(JSON.encode(success, true));
    } else {
        trace(JSON.encode(fail, true));
    }
}
Demos
Alternative Posting
Invoking the ‘Share’ dialogs
What are the “Share” dialogs?
How to invoke a “Share” dialog

protected function publishButtonClickHandler(e:Event):void {
  var options:Object = new Object();
  options.message = message_txt.text;
  options.caption = caption_txt.text;
  options.description = description_txt.text;
  options.name = name_txt.text;
  options.link = link_txt.text;
  options.picture = picture_txt.text;

    Facebook.ui('feed', options, callbackFunction);
}
Slides & Source code

            Graph API Explorer:
    https://developers.facebook.com/tools/explorer



                     GitHub:
  https://github.com/psyked/facebook-actionscript-api

                    Website:
              http://www.psyked.co.uk/

                Facebook App:
      http://apps.facebook.com/packt_facebook/

More Related Content

What's hot

ATD 13 - Enhancing your applications using Microsoft Graph API
ATD 13 - Enhancing your applications using Microsoft Graph APIATD 13 - Enhancing your applications using Microsoft Graph API
ATD 13 - Enhancing your applications using Microsoft Graph API
Dragan Panjkov
 
Planning and Configuring Extranets in SharePoint 2010
Planning and Configuring Extranets in SharePoint 2010Planning and Configuring Extranets in SharePoint 2010
Planning and Configuring Extranets in SharePoint 2010Geoff Varosky
 
What's New for Developers in SharePoint 2010
What's New for Developers in SharePoint 2010What's New for Developers in SharePoint 2010
What's New for Developers in SharePoint 2010
Geoff Varosky
 
Creating Custom Actions within SharePoint
Creating Custom Actions within SharePointCreating Custom Actions within SharePoint
Creating Custom Actions within SharePoint
Geoff Varosky
 
Interactive with-facebook
Interactive with-facebookInteractive with-facebook
Interactive with-facebook
Tien Nguyen
 
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
 
Planning and Configuring Extranets in SharePoint 2010
Planning and Configuring Extranets in SharePoint 2010Planning and Configuring Extranets in SharePoint 2010
Planning and Configuring Extranets in SharePoint 2010
Geoff Varosky
 
Planning and Configuring Extranets in SharePoint 2010
Planning and Configuring Extranets in SharePoint 2010Planning and Configuring Extranets in SharePoint 2010
Planning and Configuring Extranets in SharePoint 2010
Geoff Varosky
 
SharePoint Saturday EMEA - The Ribbon UI and Custom Actions in SharePoint 2010
SharePoint Saturday EMEA - The Ribbon UI and Custom Actions in SharePoint 2010SharePoint Saturday EMEA - The Ribbon UI and Custom Actions in SharePoint 2010
SharePoint Saturday EMEA - The Ribbon UI and Custom Actions in SharePoint 2010
Geoff Varosky
 
From SharePoint Designer to Visual Studio - Prototyping and Deploying Solutio...
From SharePoint Designer to Visual Studio - Prototyping and Deploying Solutio...From SharePoint Designer to Visual Studio - Prototyping and Deploying Solutio...
From SharePoint Designer to Visual Studio - Prototyping and Deploying Solutio...
Geoff Varosky
 
The Ribbon UI and Custom Actions in SharePoint 2010
The Ribbon UI and Custom Actions in SharePoint 2010The Ribbon UI and Custom Actions in SharePoint 2010
The Ribbon UI and Custom Actions in SharePoint 2010
Geoff Varosky
 
SPS Lisbon 2017 - Enhancing your applications using Microsoft Graph API
SPS Lisbon 2017 - Enhancing your applications using Microsoft Graph APISPS Lisbon 2017 - Enhancing your applications using Microsoft Graph API
SPS Lisbon 2017 - Enhancing your applications using Microsoft Graph API
Dragan Panjkov
 
Google Tag Manager for Ecommerce
Google Tag Manager for EcommerceGoogle Tag Manager for Ecommerce
Google Tag Manager for Ecommerce
Daytodayebay
 
SharePoint Saturday Hartford - 01/29/11 - Creating Custom Actions in SharePoi...
SharePoint Saturday Hartford - 01/29/11 - Creating Custom Actions in SharePoi...SharePoint Saturday Hartford - 01/29/11 - Creating Custom Actions in SharePoi...
SharePoint Saturday Hartford - 01/29/11 - Creating Custom Actions in SharePoi...
Geoff Varosky
 
SharePoint Saturday NYC 1/30/10 - Whats New For Developers In Share Point 2010
SharePoint Saturday NYC 1/30/10 - Whats New For Developers In Share Point 2010SharePoint Saturday NYC 1/30/10 - Whats New For Developers In Share Point 2010
SharePoint Saturday NYC 1/30/10 - Whats New For Developers In Share Point 2010
Geoff Varosky
 
SharePoint Saturday Boston 2/27/10 - Whats New For Developers In SharePoint 2010
SharePoint Saturday Boston 2/27/10 - Whats New For Developers In SharePoint 2010SharePoint Saturday Boston 2/27/10 - Whats New For Developers In SharePoint 2010
SharePoint Saturday Boston 2/27/10 - Whats New For Developers In SharePoint 2010
Geoff Varosky
 
Creating Custom Actions in SharePoint 2010
Creating Custom Actions in SharePoint 2010Creating Custom Actions in SharePoint 2010
Creating Custom Actions in SharePoint 2010
Geoff Varosky
 

What's hot (17)

ATD 13 - Enhancing your applications using Microsoft Graph API
ATD 13 - Enhancing your applications using Microsoft Graph APIATD 13 - Enhancing your applications using Microsoft Graph API
ATD 13 - Enhancing your applications using Microsoft Graph API
 
Planning and Configuring Extranets in SharePoint 2010
Planning and Configuring Extranets in SharePoint 2010Planning and Configuring Extranets in SharePoint 2010
Planning and Configuring Extranets in SharePoint 2010
 
What's New for Developers in SharePoint 2010
What's New for Developers in SharePoint 2010What's New for Developers in SharePoint 2010
What's New for Developers in SharePoint 2010
 
Creating Custom Actions within SharePoint
Creating Custom Actions within SharePointCreating Custom Actions within SharePoint
Creating Custom Actions within SharePoint
 
Interactive with-facebook
Interactive with-facebookInteractive with-facebook
Interactive with-facebook
 
Php day 2011 - Interactive-with-facebook
Php day 2011 - Interactive-with-facebookPhp day 2011 - Interactive-with-facebook
Php day 2011 - Interactive-with-facebook
 
Planning and Configuring Extranets in SharePoint 2010
Planning and Configuring Extranets in SharePoint 2010Planning and Configuring Extranets in SharePoint 2010
Planning and Configuring Extranets in SharePoint 2010
 
Planning and Configuring Extranets in SharePoint 2010
Planning and Configuring Extranets in SharePoint 2010Planning and Configuring Extranets in SharePoint 2010
Planning and Configuring Extranets in SharePoint 2010
 
SharePoint Saturday EMEA - The Ribbon UI and Custom Actions in SharePoint 2010
SharePoint Saturday EMEA - The Ribbon UI and Custom Actions in SharePoint 2010SharePoint Saturday EMEA - The Ribbon UI and Custom Actions in SharePoint 2010
SharePoint Saturday EMEA - The Ribbon UI and Custom Actions in SharePoint 2010
 
From SharePoint Designer to Visual Studio - Prototyping and Deploying Solutio...
From SharePoint Designer to Visual Studio - Prototyping and Deploying Solutio...From SharePoint Designer to Visual Studio - Prototyping and Deploying Solutio...
From SharePoint Designer to Visual Studio - Prototyping and Deploying Solutio...
 
The Ribbon UI and Custom Actions in SharePoint 2010
The Ribbon UI and Custom Actions in SharePoint 2010The Ribbon UI and Custom Actions in SharePoint 2010
The Ribbon UI and Custom Actions in SharePoint 2010
 
SPS Lisbon 2017 - Enhancing your applications using Microsoft Graph API
SPS Lisbon 2017 - Enhancing your applications using Microsoft Graph APISPS Lisbon 2017 - Enhancing your applications using Microsoft Graph API
SPS Lisbon 2017 - Enhancing your applications using Microsoft Graph API
 
Google Tag Manager for Ecommerce
Google Tag Manager for EcommerceGoogle Tag Manager for Ecommerce
Google Tag Manager for Ecommerce
 
SharePoint Saturday Hartford - 01/29/11 - Creating Custom Actions in SharePoi...
SharePoint Saturday Hartford - 01/29/11 - Creating Custom Actions in SharePoi...SharePoint Saturday Hartford - 01/29/11 - Creating Custom Actions in SharePoi...
SharePoint Saturday Hartford - 01/29/11 - Creating Custom Actions in SharePoi...
 
SharePoint Saturday NYC 1/30/10 - Whats New For Developers In Share Point 2010
SharePoint Saturday NYC 1/30/10 - Whats New For Developers In Share Point 2010SharePoint Saturday NYC 1/30/10 - Whats New For Developers In Share Point 2010
SharePoint Saturday NYC 1/30/10 - Whats New For Developers In Share Point 2010
 
SharePoint Saturday Boston 2/27/10 - Whats New For Developers In SharePoint 2010
SharePoint Saturday Boston 2/27/10 - Whats New For Developers In SharePoint 2010SharePoint Saturday Boston 2/27/10 - Whats New For Developers In SharePoint 2010
SharePoint Saturday Boston 2/27/10 - Whats New For Developers In SharePoint 2010
 
Creating Custom Actions in SharePoint 2010
Creating Custom Actions in SharePoint 2010Creating Custom Actions in SharePoint 2010
Creating Custom Actions in SharePoint 2010
 

Similar to The Flash Facebook Cookbook - FlashMidlands

Leveraging Rails to Build Facebook Apps
Leveraging Rails to Build Facebook AppsLeveraging Rails to Build Facebook Apps
Leveraging Rails to Build Facebook Apps
David Keener
 
Graph API - Facebook Developer Garage Taipei
Graph API - Facebook Developer Garage TaipeiGraph API - Facebook Developer Garage Taipei
Graph API - Facebook Developer Garage Taipei
Cardinal Blue Software
 
Facebook Platform for Developers
Facebook Platform for DevelopersFacebook Platform for Developers
Facebook Platform for Developers
Lidan Hifi
 
Microsoft Graph: Connect to essential data every app needs
Microsoft Graph: Connect to essential data every app needsMicrosoft Graph: Connect to essential data every app needs
Microsoft Graph: Connect to essential data every app needs
Microsoft Tech Community
 
Microsoft Graph: Connect to essential data every app needs
Microsoft Graph: Connect to essential data every app needsMicrosoft Graph: Connect to essential data every app needs
Microsoft Graph: Connect to essential data every app needs
Microsoft Tech Community
 
Hi5 Open Social
Hi5   Open SocialHi5   Open Social
Hi5 Open Social
Julia Foxworthy
 
Creating Professional Applications with the LinkedIn API
Creating Professional Applications with the LinkedIn APICreating Professional Applications with the LinkedIn API
Creating Professional Applications with the LinkedIn API
Kirsten Hunter
 
SharePoint Fest DC 2018 - Everything your need to know about the Microsoft Gr...
SharePoint Fest DC 2018 - Everything your need to know about the Microsoft Gr...SharePoint Fest DC 2018 - Everything your need to know about the Microsoft Gr...
SharePoint Fest DC 2018 - Everything your need to know about the Microsoft Gr...
Sébastien Levert
 
[D6]deview 2012 creating an attractive platform
[D6]deview 2012 creating an attractive platform[D6]deview 2012 creating an attractive platform
[D6]deview 2012 creating an attractive platformNAVER D2
 
Introduction to Facebook JavaScript & Python SDK
Introduction to Facebook JavaScript & Python SDKIntroduction to Facebook JavaScript & Python SDK
Introduction to Facebook JavaScript & Python SDK
Colin Su
 
Open social & cmis oasistc-20100712
Open social & cmis   oasistc-20100712Open social & cmis   oasistc-20100712
Open social & cmis oasistc-20100712
weitzelm
 
Facebook Apps Development 101 (Java)
Facebook Apps Development 101 (Java)Facebook Apps Development 101 (Java)
Facebook Apps Development 101 (Java)
Damon Widjaja
 
MozCon Seattle 2011 - Social Design
MozCon Seattle 2011 - Social DesignMozCon Seattle 2011 - Social Design
MozCon Seattle 2011 - Social DesignMat Clayton
 
Introducing Hangout Apps
Introducing Hangout AppsIntroducing Hangout Apps
Introducing Hangout Apps
Jonathan Beri
 
Facebook api
Facebook api Facebook api
Facebook api
snipermkd
 
Facebook API
Facebook APIFacebook API
Facebook APIsnipermkd
 
Better APIs with GraphQL
Better APIs with GraphQL Better APIs with GraphQL
Better APIs with GraphQL
Josh Price
 
Node social
Node socialNode social
Node social
orkaplan
 
Facebook Open Graph Protocol and Graph API (NoVA Code Camp 2010.1)
Facebook Open Graph Protocol and Graph API (NoVA Code Camp 2010.1)Facebook Open Graph Protocol and Graph API (NoVA Code Camp 2010.1)
Facebook Open Graph Protocol and Graph API (NoVA Code Camp 2010.1)
Chris Busse
 
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
 

Similar to The Flash Facebook Cookbook - FlashMidlands (20)

Leveraging Rails to Build Facebook Apps
Leveraging Rails to Build Facebook AppsLeveraging Rails to Build Facebook Apps
Leveraging Rails to Build Facebook Apps
 
Graph API - Facebook Developer Garage Taipei
Graph API - Facebook Developer Garage TaipeiGraph API - Facebook Developer Garage Taipei
Graph API - Facebook Developer Garage Taipei
 
Facebook Platform for Developers
Facebook Platform for DevelopersFacebook Platform for Developers
Facebook Platform for Developers
 
Microsoft Graph: Connect to essential data every app needs
Microsoft Graph: Connect to essential data every app needsMicrosoft Graph: Connect to essential data every app needs
Microsoft Graph: Connect to essential data every app needs
 
Microsoft Graph: Connect to essential data every app needs
Microsoft Graph: Connect to essential data every app needsMicrosoft Graph: Connect to essential data every app needs
Microsoft Graph: Connect to essential data every app needs
 
Hi5 Open Social
Hi5   Open SocialHi5   Open Social
Hi5 Open Social
 
Creating Professional Applications with the LinkedIn API
Creating Professional Applications with the LinkedIn APICreating Professional Applications with the LinkedIn API
Creating Professional Applications with the LinkedIn API
 
SharePoint Fest DC 2018 - Everything your need to know about the Microsoft Gr...
SharePoint Fest DC 2018 - Everything your need to know about the Microsoft Gr...SharePoint Fest DC 2018 - Everything your need to know about the Microsoft Gr...
SharePoint Fest DC 2018 - Everything your need to know about the Microsoft Gr...
 
[D6]deview 2012 creating an attractive platform
[D6]deview 2012 creating an attractive platform[D6]deview 2012 creating an attractive platform
[D6]deview 2012 creating an attractive platform
 
Introduction to Facebook JavaScript & Python SDK
Introduction to Facebook JavaScript & Python SDKIntroduction to Facebook JavaScript & Python SDK
Introduction to Facebook JavaScript & Python SDK
 
Open social & cmis oasistc-20100712
Open social & cmis   oasistc-20100712Open social & cmis   oasistc-20100712
Open social & cmis oasistc-20100712
 
Facebook Apps Development 101 (Java)
Facebook Apps Development 101 (Java)Facebook Apps Development 101 (Java)
Facebook Apps Development 101 (Java)
 
MozCon Seattle 2011 - Social Design
MozCon Seattle 2011 - Social DesignMozCon Seattle 2011 - Social Design
MozCon Seattle 2011 - Social Design
 
Introducing Hangout Apps
Introducing Hangout AppsIntroducing Hangout Apps
Introducing Hangout Apps
 
Facebook api
Facebook api Facebook api
Facebook api
 
Facebook API
Facebook APIFacebook API
Facebook API
 
Better APIs with GraphQL
Better APIs with GraphQL Better APIs with GraphQL
Better APIs with GraphQL
 
Node social
Node socialNode social
Node social
 
Facebook Open Graph Protocol and Graph API (NoVA Code Camp 2010.1)
Facebook Open Graph Protocol and Graph API (NoVA Code Camp 2010.1)Facebook Open Graph Protocol and Graph API (NoVA Code Camp 2010.1)
Facebook Open Graph Protocol and Graph API (NoVA Code Camp 2010.1)
 
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
 

More from James Ford

Virtualisation - Vagrant and Docker
Virtualisation - Vagrant and DockerVirtualisation - Vagrant and Docker
Virtualisation - Vagrant and Docker
James Ford
 
The Magic of Charts
The Magic of ChartsThe Magic of Charts
The Magic of Charts
James Ford
 
Telling Tales and Solving Crimes with New Relic
Telling Tales and Solving Crimes with New RelicTelling Tales and Solving Crimes with New Relic
Telling Tales and Solving Crimes with New Relic
James Ford
 
ES6, WTF?
ES6, WTF?ES6, WTF?
ES6, WTF?
James Ford
 
Web fonts FTW
Web fonts FTWWeb fonts FTW
Web fonts FTW
James Ford
 
Git 101: Force-sensitive to Jedi padawan
Git 101: Force-sensitive to Jedi padawanGit 101: Force-sensitive to Jedi padawan
Git 101: Force-sensitive to Jedi padawan
James Ford
 
Responsive images in 10 minutes
Responsive images in 10 minutesResponsive images in 10 minutes
Responsive images in 10 minutes
James Ford
 
'Hack to the future' - Hackathons at MMT Digital
'Hack to the future' - Hackathons at MMT Digital'Hack to the future' - Hackathons at MMT Digital
'Hack to the future' - Hackathons at MMT Digital
James Ford
 
Fork me!
Fork me!Fork me!
Fork me!
James Ford
 
Grunt training deck
Grunt training deckGrunt training deck
Grunt training deck
James Ford
 
What the HTML? - The Holy Grail
What the HTML? - The Holy GrailWhat the HTML? - The Holy Grail
What the HTML? - The Holy Grail
James Ford
 
Testacular
TestacularTestacular
Testacular
James Ford
 
Agile Partners
Agile PartnersAgile Partners
Agile Partners
James Ford
 

More from James Ford (13)

Virtualisation - Vagrant and Docker
Virtualisation - Vagrant and DockerVirtualisation - Vagrant and Docker
Virtualisation - Vagrant and Docker
 
The Magic of Charts
The Magic of ChartsThe Magic of Charts
The Magic of Charts
 
Telling Tales and Solving Crimes with New Relic
Telling Tales and Solving Crimes with New RelicTelling Tales and Solving Crimes with New Relic
Telling Tales and Solving Crimes with New Relic
 
ES6, WTF?
ES6, WTF?ES6, WTF?
ES6, WTF?
 
Web fonts FTW
Web fonts FTWWeb fonts FTW
Web fonts FTW
 
Git 101: Force-sensitive to Jedi padawan
Git 101: Force-sensitive to Jedi padawanGit 101: Force-sensitive to Jedi padawan
Git 101: Force-sensitive to Jedi padawan
 
Responsive images in 10 minutes
Responsive images in 10 minutesResponsive images in 10 minutes
Responsive images in 10 minutes
 
'Hack to the future' - Hackathons at MMT Digital
'Hack to the future' - Hackathons at MMT Digital'Hack to the future' - Hackathons at MMT Digital
'Hack to the future' - Hackathons at MMT Digital
 
Fork me!
Fork me!Fork me!
Fork me!
 
Grunt training deck
Grunt training deckGrunt training deck
Grunt training deck
 
What the HTML? - The Holy Grail
What the HTML? - The Holy GrailWhat the HTML? - The Holy Grail
What the HTML? - The Holy Grail
 
Testacular
TestacularTestacular
Testacular
 
Agile Partners
Agile PartnersAgile Partners
Agile Partners
 

Recently uploaded

SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdfSAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
Peter Spielvogel
 
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
UiPathCommunity
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Aggregage
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
nkrafacyberclub
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Thierry Lestable
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
Alison B. Lowndes
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
Sri Ambati
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 
Welocme to ViralQR, your best QR code generator.
Welocme to ViralQR, your best QR code generator.Welocme to ViralQR, your best QR code generator.
Welocme to ViralQR, your best QR code generator.
ViralQR
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
sonjaschweigert1
 

Recently uploaded (20)

SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdfSAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
 
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
Welocme to ViralQR, your best QR code generator.
Welocme to ViralQR, your best QR code generator.Welocme to ViralQR, your best QR code generator.
Welocme to ViralQR, your best QR code generator.
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
 

The Flash Facebook Cookbook - FlashMidlands

  • 1. Me. James Ford http://www.psyked.co.uk/ @psyked_james Product Development @ MMT Digital Web (HTML, CSS, JavaScript) Flash Platform (Flash, Flex, AIR) Mobile (Obj-C, ELIPS, Titanium, Corona SDK)
  • 2. Flash Facebook Cookbook Published August 2011 Packt Publishing - Facebook Graph API 1.6 - FQL - , & , - Introduction to Facebook Graph API, core concepts & lots of simple demo applications.
  • 3. Initial questions • What data is available from Facebook? • How is that data structured? • How do we connect to the Graph API? • How do we locate information on Facebook? • What data-access controls are in place?
  • 5. What is the Graph API? • The API for accessing data held by Facebook • Uses OAuth 2.0 • REST-style API • JSON-encoded response objects
  • 6. The Graph API is not: • The Open Graph Protocol • FQL (Facebook Query Language) • Connect, FBML or Legacy REST API
  • 8. Data available from Facebook Without Authentication (Access Tokens) • User ID, Combined name & Profile image • Any Publicly-accessible data: Users, Pages, Places, Groups & Events With Authentication • Profile data: Name, Gender • Friend lists, Mutual friend information With Authentication + Extended Permissions • Profile data: Birthday, Bio, Relationships, Religion, Politics... (everything in your profile, basically) • News feeds, Profile feeds • Checkins, Notes, Photos, Videos • Comments, Likes
  • 10. Facebook data types Common types And the less common... • Album • Insights • Application • Message • Checkin • Note • Comment • Question • Event • QuestionOption • Group • Review • Link • Subscription • Page • Thread • Photo • Post • Status message • User • Video
  • 11. Graph API Objects Everything has a unique Id, and can be accessed directly: • Users: https://graph.facebook.com/btaylor (Bret Taylor) • Pages: https://graph.facebook.com/cocacola (Coca-Cola page) • Events: https://graph.facebook.com/251906384206 (Facebook Developer Garage Austin) • Groups: https://graph.facebook.com/195466193802264 (Facebook Developers group) • Applications: https://graph.facebook.com/2439131959 (the Graffiti app) • Status messages: https://graph.facebook.com/367501354973 (A status message from Bret) • Photos: https://graph.facebook.com/98423808305 (A photo from the Coca-Cola page) • Photo albums: https://graph.facebook.com/99394368305 (Coca-Cola's wall photos) • Profile pictures: https://graph.facebook.com/psyked/picture (your profile picture) • Videos: https://graph.facebook.com/817129783203 (A Facebook tech talk on Graph API) • Notes: https://graph.facebook.com/122788341354 (Note announcing Facebook for iPhone 3.0) • Checkins: https://graph.facebook.com/414866888308 (Check-in at a pizzeria)
  • 12. Graph API Connections Graph API Connections are used to represent relationships in the ‘social graph’, and return a JSON-encoded Array of objects. • Friends: https://graph.facebook.com/me/friends • News feed: https://graph.facebook.com/me/home • Profile feed (Wall): https://graph.facebook.com/me/feed • Likes: https://graph.facebook.com/me/likes • Books: https://graph.facebook.com/me/books • Permissions: https://graph.facebook.com/me/permissions • Photo Tags: https://graph.facebook.com/me/photos • Photo Albums: https://graph.facebook.com/me/albums • Video Tags: https://graph.facebook.com/me/videos • Video Uploads: https://graph.facebook.com/me/videos/uploaded • Events: https://graph.facebook.com/me/events • Groups: https://graph.facebook.com/me/groups • Checkins: https://graph.facebook.com/me/checkins
  • 13. A Public Graph API Object GET http://graph.facebook.com/platform { "id": "19292868552", "name": "Facebook Platform", "picture": "http://profile.ak.fbcdn.net/hprofile-ak- ash2/276791_19292868552_1958181823_s.jpg", "link": "https://www.facebook.com/platform", "likes": 3403793, "category": "Product/service", "website": "http://developers.facebook.com", "username": "platform", "founded": "2007", "company_overview": "Facebook Platform enables anyone to build social apps on Facebook and the web.", "mission": "To make the web more open and social." }
  • 14. A Private Graph API Object GET https://graph.facebook.com/me?access_token=AAAAAAITEgh... { "id": "#########", "name": "James Ford", "first_name": "James", "last_name": "Ford", "link": "https://www.facebook.com/psyked", "username": "psyked", "birthday": "##/##/####", "hometown": { "id": "108126319208135", "name": "Stamford, Lincolnshire" }, "gender": "male", "website": "http://www.psyked.co.uk", "locale": "en_GB", "verified": true, "updated_time": "2011-10-02T10:37:20+0000" }
  • 15. A Graph API Connection GET https://graph.facebook.com/me/likes?access_token=AAAAA... { "data": [ { "name": "CodeBoxed", "category": "Computers/internet", "id": "126122064123731", "created_time": "2011-09-02T18:09:50+0000" }, { "name": "The Grand Design", "category": "Book", "id": "153522094682666", "created_time": "2011-08-21T22:08:49+0000" }, { "name": "on AIR Tour Europe 2008", "category": "Community", "id": "8295947366", "created_time": "2008-02-20T10:02:34+0000" } ] }
  • 16.
  • 19. Connecting to the Graph API
  • 21. JavaScript & the Graph API <div id="fb-root"></div> <script src="http://connect.facebook.net/en_US/all.js"></script> <script type="text/javascript"> FB.init({ appId:'APP_ID' }); FB.login(function(response) { if (response.session) { console.log('Welcome! Fetching your information.... '); FB.api('/me', function(response) { console.log('Good to see you, ' + response.name + '.'); }); } else { console.log('User cancelled login or did not fully authorize.'); } }); </script>
  • 22. ActionScript & the Graph API import com.facebook.graph.Facebook; Facebook.init('API_KEY', responseHandler, { appId:'APP_ID' }); private function responseHandler( success:Object, fail:Object ):void { if (success) { Facebook.api('/platform', requestResponseHandler); } else { Facebook.login(loginResponseHandler); } } private function loginResponseHandler(success:Object, fail:Object):void { if (success) { Facebook.api('/platform', requestResponseHandler); } else { trace('Unable to log in'); } } private function requestResponseHandler(success:Object, fail:Object):void { if (success) { trace(JSON.encode(success, true)); } }
  • 23.
  • 24.
  • 25. What happens when I... Don’t have access?
  • 26. Requesting restricted data Loading objects without an access token { "error": { "message": "An access token is required to request this resource.", "type": "OAuthException" } } Loading objects without permissions { "error": { "message": "mailbox requires the read_mailbox extended permission.", "type": "OAuthException" } }
  • 28. Extended Permissions • Album: user_photos, friends_photos, publish_stream • Checkin: user_checkins, friends_checkins, publish_stream • Comment: publish_stream • Event: user_event, friends_event, publish_stream • Group: user_groups, friends_groups, publish_stream • Insights: read_insights • Link: read_stream, publish_stream • Message: read_mailbox • Notes: user_notes, friends_notes • Page: manage_pages • Photo: user_photos, friends_photos • Post / Status message: read_stream, publish_stream • User: user_about_me, friends_about_me, user_birthday, friends_birthday, user_education_history, friends_education_history, email, user_hometown, friends_hometown, user_relationship_details, friends_relationship_details, user_location, friends_location, user_religon_politics, friends_religion_politics, user_likes, friends_likes, user_relationships, friends_relationships, user_websites, friends_websites, user_work_history, friends_work_history • Video: user_videos, friends_videos, publish_stream
  • 29. Requesting Permissions var options:Object = {}; options.perms = new Array("user_about_me", "email", "friends_birthday"); Facebook.login(loginResponseHandler, options); private function loginResponseHandler(success:Object, fail:Object):void { if (success) { Facebook.api('/platform', requestResponseHandler); } else { trace('Unable to log in'); } }
  • 30. Checking for Permissions var missingPermissions:Array = new Array(); private function requestPermissionsInfo():void { var permissions:Array = new Array("read_stream", "publish_stream"); Facebook.fqlQuery("SELECT {0} FROM permissions WHERE uid = me() ", onFQLResponse, [permissions.toString()]); } private function onFQLResponse(success:Object, fail:Object):void { [{ missingPermissions = new Array(); "email":0, var results:Array = success as Array; "publish_stream":1, if (success && results) { "read_stream":1 for (var i:int = 0; i < results.length; i++) { }] var queryResult:Object = results[i]; for (var param:String in queryResult) { if (Boolean(queryResult[param]) == false) { missingPermissions.push(param); } } } } }
  • 31.
  • 32. Creating & Modifying Data on Facebook
  • 33. Posting data to the Graph API var options:Object = new Object(); options.name = "I found a trophy"; options.caption "100001986549853_202809986461885"} {"id": = "Gold trophy"; options.description = "I found a Gold trophy while using ..."; options.link = "http://apps.facebook.com/packt_facebook/"; options.picture = "http://facebook.psyked.co.uk/packt/images/gold.png"; Facebook.api("me/feed", responseHandler, options, "post"); private function responseHandler(success:Object, fail:Object):void { if (success) { trace(JSON.encode(success, true)); } else { trace(JSON.encode(fail, true)); } }
  • 34. Posting image data - webcam import mx.graphics.ImageSnapshot; var options:Object = {}; options.fileName = "webcam.png"; options.image = ImageSnapshot.captureBitmapData(webcam_display); options.message = "Image caption"; Facebook.api("me/photos", photoUploadComplete, options, "post");
  • 35. Posting image data - FileReference var options:Object = {}; options.fileName = fr.name; options.image = fr.data; var fileExtension:String = fr.name.split(".")[fr.name.split(".").length-1]; switch (fileExtension) { case "gif": options.contentType = "image/gif"; break; case "png": options.contentType = "image/png"; break; case "jpeg": case "jpg": options.contentType = "image/jpeg"; break; } options.message = "Image caption"; Facebook.api("me/photos", photoUploadComplete, options, "post");
  • 36. Editing existing Objects • Editing objects (that can be edited) is done by var options:Object = new Object(); making a POST request to an Objects’ URL. options.name = "I found a trophy"; options.caption = "Gold trophy"; options.description = "I found a Gold trophy while using ..."; options.link = "http://apps.facebook.com/packt_facebook/"; options.picture = "http://facebook.psyked.co.uk/packt/images/gold.png"; Application, Album, Event, Group and User Facebook.api("me/feed", responseHandler, options, "post"); objects have properties that can be edited. private function responseHandler(success:Object, fail:Object):void { if (success) { trace(JSON.encode(success, true)); } else { trace(JSON.encode(fail, true)); } }
  • 37. Deleting existing Objects var options:Object = new Object(); options.method = "delete"; Facebook.api("10150322337577749", responseHandler, options, "post"); private function responseHandler(success:Object, fail:Object):void { if (success) { trace(JSON.encode(success, true)); } else { trace(JSON.encode(fail, true)); } }
  • 38. Demos
  • 39. Alternative Posting Invoking the ‘Share’ dialogs
  • 40. What are the “Share” dialogs?
  • 41. How to invoke a “Share” dialog protected function publishButtonClickHandler(e:Event):void { var options:Object = new Object(); options.message = message_txt.text; options.caption = caption_txt.text; options.description = description_txt.text; options.name = name_txt.text; options.link = link_txt.text; options.picture = picture_txt.text; Facebook.ui('feed', options, callbackFunction); }
  • 42. Slides & Source code Graph API Explorer: https://developers.facebook.com/tools/explorer GitHub: https://github.com/psyked/facebook-actionscript-api Website: http://www.psyked.co.uk/ Facebook App: http://apps.facebook.com/packt_facebook/

Editor's Notes

  1. Facebook is...For developers, it gives us (users, connections, possible invites)Find the SDK download link. Where did the SDK come from?Desktop &amp; Web versions of the SDK. Both similar, different logins, I’m going to focus on the Flash Player version.Log into Facebook.com/developers and demo the interface.What is a Facebook application? (Canvas, non-canvas)The Graph API is one of the (the main) API for applications to get data from FB.
  2. So, requesting Permissions is as simple as adding their code name in the options of a login request.Put in all the permissions, and Facebook will handle the process of working out what you have, and what you need.However, there’s a downside to requesting permissions, and that’s because Facebook makes it explicitly clear what permissions your app is requesting, and what your application can do with them. Too many permissions = turn off.Golden rule is, “if you don’t need those permissions immediately, don’t ask for them”.
  3. Although you should be handling errors correctly, preventative measures and checking before performing actions are always better.Retrieving details about Extended Permissions can’t be done strictly with the Graph API, but we can retrieve this information through FQL (Facebook Query Language). FQL is an SQL-like syntax for querying Facebook.We log in with no permissions (or as little as we can get away with), and then query FQL to get a Dictionary object of permissions. Before you make a request that requires permissions, you check the object, and if you need those permissions, call the login request again, this time with a permissions object.
  4. The API is REST-based, but we can’t make anything other than GET or POST requests in Flash (or JavaScript).Instead, we can supply a method parameter, with a value of delete.The request URL is the unique Facebook Id of the object you’re deleting.