Packagecom.facebook.graph
Classpublic class FacebookDesktop
InheritanceFacebookDesktop Inheritance com.facebook.graph.core.AbstractFacebook

For use in AIR, to access the Facebook Graph API from the desktop.



Public Properties
 PropertyDefined by
  locale : String
[static][write-only]
FacebookDesktop
  manageSession : Boolean
[static][write-only] Setting to true (default), this class will manage the session and access token internally.
FacebookDesktop
Public Methods
 MethodDefined by
  
Creates a new FacebookDesktop instance
FacebookDesktop
  
api(method:String, callback:Function, params:String = null, requestMethod:* = GET):void
[static] Makes a new request on the Facebook Graph API.
FacebookDesktop
  
callRestAPI(methodName:String, callback:Function = null, values:String = null, requestMethod:* = GET):void
[static] Used to make old style RESTful API calls on Facebook.
FacebookDesktop
  
deleteObject(method:String, callback:Function):void
[static] Deletes an object from Facebook.
FacebookDesktop
  
fqlMultiQuery(queries:FQLMultiQuery, callback:Function = null, parser:IResultParser = null):void
[static] Executes an FQL multiquery on api.facebook.com.
FacebookDesktop
  
fqlQuery(query:String, callback:Function = null, values:Object = null):void
[static] Executes an FQL query on api.facebook.com.
FacebookDesktop
  
getImageUrl(id:String, type:String = null):String
[static] Utility method to format a picture URL, in order to load an image from Facebook.
FacebookDesktop
  
getRawResult(data:Object):Object
[static] Returns a reference to the entire raw object Facebook returns (including paging, etc.).
FacebookDesktop
  
getSession():FacebookSession
[static] Synchronous call to return the current user's session.
FacebookDesktop
  
hasNext(data:Object):Boolean
[static] Asks if another page exists after this result object.
FacebookDesktop
  
hasPrevious(data:Object):Boolean
[static] Asks if a page exists before this result object.
FacebookDesktop
  
init(applicationId:String, callback:Function = null, accessToken:String = null):void
[static] Initializes this Facebook singleton with your application ID.
FacebookDesktop
  
login(callback:Function, ... extendedPermissions):void
[static] Opens a new login window so the current user can log in to Facebook.
FacebookDesktop
  
logout(callback:Function = null, appOrigin:String = null):void
[static] Clears a user's local session.
FacebookDesktop
  
nextPage(data:Object, callback:Function):void
[static] Retrieves the next page that is associated with result object passed in.
FacebookDesktop
  
postData(method:String, callback:Function, params:* = null):void
[static] Shortcut method to post data to Facebook.
FacebookDesktop
  
previousPage(data:Object, callback:Function):void
[static] Retrieves the previous page that is associated with result object passed in.
FacebookDesktop
  
requestExtendedPermissions(callback:Function, ... extendedPermissions):void
[static] Opens a new window that asks the current user for extended permissions.
FacebookDesktop
Protected Methods
 MethodDefined by
  
handleLogout(result:Object, fail:Object):void
FacebookDesktop
Property detail
localeproperty
locale:String  [write-only]Implementation
    public function set locale(value:String):void
manageSessionproperty 
manageSession:Boolean  [write-only]

Setting to true (default), this class will manage the session and access token internally. Setting to false, no session management will occur and the end developer must save the session manually.

Implementation
    public function set manageSession(value:Boolean):void
Constructor detail
FacebookDesktop()constructor
public function FacebookDesktop()

Creates a new FacebookDesktop instance

Method detail
api()method
public static function api(method:String, callback:Function, params:String = null, requestMethod:* = GET):void

Makes a new request on the Facebook Graph API.

Parameters
method:String — The method to call on the Graph API. For example, to load the user's current friends, pass in /me/friends
 
callback:Function — Method that will be called when this request is complete The handler must have the signature of callback(result:Object, fail:Object); On success, result will be the object data returned from Facebook. On fail, result will be null and fail will contain information about the error.
 
params:String (default = null) — Any parameters to pass to Facebook. For example, you can pass {file:myPhoto, message:'Some message'}; this will upload a photo to Facebook.
 
requestMethod:* (default = GET) — The URLRequestMethod used to send values to Facebook. The graph API follows correct Request method conventions. GET will return data from Facebook. POST will send data to Facebook. DELETE will delete an object from Facebook.

See also

flash.net.URLRequestMethod
http://developers.facebook.com/docs/api
callRestAPI()method 
public static function callRestAPI(methodName:String, callback:Function = null, values:String = null, requestMethod:* = GET):void

Used to make old style RESTful API calls on Facebook. Normally, you would use the Graph API to request data. This method is here in case you need to use an old method, such as FQL.

Parameters
methodName:String — Name of the method to call on api.facebook.com (ex: fql.query).
 
callback:Function (default = null) — Any values to pass to this request.
 
values:String (default = null) — URLRequestMethod used to send data to Facebook.
 
requestMethod:* (default = GET)

See also

com.facebook.graph.net.FacebookDesktop.request()
deleteObject()method 
public static function deleteObject(method:String, callback:Function):void

Deletes an object from Facebook. The current user must have granted extended permission to delete the corresponding object, or an error will be returned.

Parameters
method:String — The id and connection of the object to delete. For example, /POST_ID/like to remove a like from a message.
 
callback:Function

See also

http://developers.facebook.com/docs/api#deleting
com.facebook.graph.net.FacebookDesktop.request()
fqlMultiQuery()method 
public static function fqlMultiQuery(queries:FQLMultiQuery, callback:Function = null, parser:IResultParser = null):void

Executes an FQL multiquery on api.facebook.com.

Parameters
queries:FQLMultiQuery — FQLMultiQuery The FQL queries to execute.
 
callback:Function (default = null) — IResultParser The parser used to parse result into object of name/value pairs.
 
parser:IResultParser (default = null)

See also

http://developers.facebook.com/docs/reference/fql/
com.facebook.graph.net.Facebook.callRestAPI()
fqlQuery()method 
public static function fqlQuery(query:String, callback:Function = null, values:Object = null):void

Executes an FQL query on api.facebook.com.

Parameters
query:String — The FQL query string to execute.
 
callback:Function (default = null) — Replaces string values in the in the query. ie. Replaces {digit} or {id} with the corresponding key-value in the values object
 
values:Object (default = null)

See also

http://developers.facebook.com/docs/reference/fql/
com.facebook.graph.net.Facebook.callRestAPI()
getImageUrl()method 
public static function getImageUrl(id:String, type:String = null):String

Utility method to format a picture URL, in order to load an image from Facebook.

Parameters
id:String — The id you wish to load an image from.
 
type:String (default = null) — The size of image to display from Facebook (square, small, or large).

Returns
String

See also

getRawResult()method 
public static function getRawResult(data:Object):Object

Returns a reference to the entire raw object Facebook returns (including paging, etc.).

Parameters
data:Object — The result object.

Returns
Object

See also

getSession()method 
public static function getSession():FacebookSession

Synchronous call to return the current user's session.

Returns
FacebookSession
handleLogout()method 
protected function handleLogout(result:Object, fail:Object):voidParameters
result:Object
 
fail:Object
hasNext()method 
public static function hasNext(data:Object):Boolean

Asks if another page exists after this result object.

Parameters
data:Object — The result object.

Returns
Boolean

See also

hasPrevious()method 
public static function hasPrevious(data:Object):Boolean

Asks if a page exists before this result object.

Parameters
data:Object — The result object.

Returns
Boolean

See also

init()method 
public static function init(applicationId:String, callback:Function = null, accessToken:String = null):void

Initializes this Facebook singleton with your application ID. You must call this method first.

Parameters
applicationId:String — The application ID you created at http://www.facebook.com/developers/apps.php
 
callback:Function (default = null) — (Optional) Method to call when initialization is complete. The handler must have the signature of callback(success:Object, fail:Object); Success will be a FacebookSession if successful, or null if not.
 
accessToken:String (default = null) — (Optional) If you have a previously saved access_token, you can pass it in here.
login()method 
public static function login(callback:Function, ... extendedPermissions):void

Opens a new login window so the current user can log in to Facebook.

Parameters
callback:Function — The method to call when login is successful. The handler must have the signature of callback(success:Object, fail:Object); Success will be a FacebookSession if successful, or null if not.
 
... extendedPermissions — (Optional) Array of extended permissions to ask the user for once they are logged in. For the most current list of extended permissions, visit http://developers.facebook.com/docs/authentication/permissions

See also

logout()method 
public static function logout(callback:Function = null, appOrigin:String = null):void

Clears a user's local session. This method is synchronous, since its method does not log the user out of Facebook, only the current application.

Parameters
callback:Function (default = null) — (Optional) Method to call when logout is done.
 
appOrigin:String (default = null) — (Optional) The site url specified for your app. Required for clearing html window cookie.
nextPage()method 
public static function nextPage(data:Object, callback:Function):void

Retrieves the next page that is associated with result object passed in.

Parameters
data:Object — The result object.
 
callback:Function — Method that will be called when this request is complete The handler must have the signature of callback(result:Object, fail:Object); On success, result will be the object data returned from Facebook. On fail, result will be null and fail will contain information about the error.

See also

com.facebook.graph.net.FacebookDesktop.request()
http://developers.facebook.com/docs/api#reading
postData()method 
public static function postData(method:String, callback:Function, params:* = null):void

Shortcut method to post data to Facebook. Alternatively, you can call FacebookDesktop.request and use POST for requestMethod.

Parameters
method:String
 
callback:Function
 
params:* (default = null)

See also

com.facebook.graph.net.FacebookDesktop.request()
previousPage()method 
public static function previousPage(data:Object, callback:Function):void

Retrieves the previous page that is associated with result object passed in.

Parameters
data:Object — The result object.
 
callback:Function — Method that will be called when this request is complete The handler must have the signature of callback(result:Object, fail:Object); On success, result will be the object data returned from Facebook. On fail, result will be null and fail will contain information about the error.

See also

com.facebook.graph.net.FacebookDesktop.request()
http://developers.facebook.com/docs/api#reading
requestExtendedPermissions()method 
public static function requestExtendedPermissions(callback:Function, ... extendedPermissions):void

Opens a new window that asks the current user for extended permissions.

Parameters
callback:Function — The method to call after request for permissions.
 
... extendedPermissions — Array of extended permissions to ask the user for once they are logged in.

See also

com.facebook.graph.net.FacebookDesktop.login()
http://developers.facebook.com/docs/authentication/permissions