SlideShare uma empresa Scribd logo
1 de 42
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/

Mais conteúdo relacionado

Mais procurados

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 APIDragan 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 2010Geoff Varosky
 
Creating Custom Actions within SharePoint
Creating Custom Actions within SharePointCreating Custom Actions within SharePoint
Creating Custom Actions within SharePointGeoff Varosky
 
Interactive with-facebook
Interactive with-facebookInteractive with-facebook
Interactive with-facebookTien 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 2010Geoff 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 2010Geoff 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 2010Geoff 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 2010Geoff 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 APIDragan Panjkov
 
Google Tag Manager for Ecommerce
Google Tag Manager for EcommerceGoogle Tag Manager for Ecommerce
Google Tag Manager for EcommerceDaytodayebay
 
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 2010Geoff 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 2010Geoff Varosky
 
Creating Custom Actions in SharePoint 2010
Creating Custom Actions in SharePoint 2010Creating Custom Actions in SharePoint 2010
Creating Custom Actions in SharePoint 2010Geoff Varosky
 

Mais procurados (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
 

Semelhante a 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 AppsDavid Keener
 
Graph API - Facebook Developer Garage Taipei
Graph API - Facebook Developer Garage TaipeiGraph API - Facebook Developer Garage Taipei
Graph API - Facebook Developer Garage TaipeiCardinal Blue Software
 
Facebook Platform for Developers
Facebook Platform for DevelopersFacebook Platform for Developers
Facebook Platform for DevelopersLidan 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 needsMicrosoft 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 needsMicrosoft Tech Community
 
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 APIKirsten 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 SDKColin Su
 
Open social & cmis oasistc-20100712
Open social & cmis   oasistc-20100712Open social & cmis   oasistc-20100712
Open social & cmis oasistc-20100712weitzelm
 
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 AppsJonathan 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 socialorkaplan
 
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
 

Semelhante a 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
 

Mais de James Ford

Virtualisation - Vagrant and Docker
Virtualisation - Vagrant and DockerVirtualisation - Vagrant and Docker
Virtualisation - Vagrant and DockerJames Ford
 
The Magic of Charts
The Magic of ChartsThe Magic of Charts
The Magic of ChartsJames 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 RelicJames 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 padawanJames Ford
 
Responsive images in 10 minutes
Responsive images in 10 minutesResponsive images in 10 minutes
Responsive images in 10 minutesJames 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 DigitalJames Ford
 
Grunt training deck
Grunt training deckGrunt training deck
Grunt training deckJames Ford
 
What the HTML? - The Holy Grail
What the HTML? - The Holy GrailWhat the HTML? - The Holy Grail
What the HTML? - The Holy GrailJames Ford
 
Agile Partners
Agile PartnersAgile Partners
Agile PartnersJames Ford
 

Mais de 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
 

Último

Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
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 2024The Digital Insurer
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
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 DevelopmentsTrustArc
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 

Último (20)

Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
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
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
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
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 

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/

Notas do Editor

  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.