Packagecom.facebook.graph
Classpublic class Facebook
InheritanceFacebook Inheritance AbstractFacebook Inheritance Object

Main class to connect to Facebook Graph API services. For use on the web or mobile to call Facebook API methods. This class abstracts the Facebook Javascript SDK to handle authentication showing sharing windows and maintaining the current session.



Public Properties
 PropertyDefined By
  locale : String
[static] [write-only]
Facebook
Public Methods
 MethodDefined By
  
Creates an instance of Facebook.
Facebook
  
addJSEventListener(event:String, listener:Function):void
[static] Utility method to add listeners to the underlying Facebook library.
Facebook
  
api(method:String, callback:Function = null, params:* = null, requestMethod:String = GET):void
[static] Makes a new request on the Facebook Graph API.
Facebook
  
batchRequest(batch:Batch, callback:Function = null):void
[static] Executes a batch api operation on facebook.
Facebook
  
callJS(methodName:String, params:Object):void
[static] Calls an arbitrary Javascript method on the underlying HTML page.
Facebook
  
callRestAPI(methodName:String, callback:Function, values:* = null, requestMethod:String = GET):void
[static] Used to make old style RESTful API calls on Facebook.
Facebook
  
deleteObject(method:String, callback:Function = null):void
[static] Deletes an object from Facebook.
Facebook
  
fqlMultiQuery(queries:FQLMultiQuery, callback:Function = null, parser:IResultParser = null):void
[static] Executes an FQL multiquery on api.facebook.com.
Facebook
  
fqlQuery(query:String, callback:Function = null, values:Object = null):void
[static] Executes an FQL query on api.facebook.com.
Facebook
  
[static] Synchronous method to retrieve the current user's auth response.
Facebook
  
getImageUrl(id:String, type:String = null):String
[static] Utility method to format a picture URL, in order to load an image from Facebook.
Facebook
  
[static] Asynchronous method to get the user's current session from Facebook.
Facebook
  
getRawResult(data:Object):Object
[static] Returns a reference to the entire raw object Facebook returns (including paging, etc.).
Facebook
  
hasJSEventListener(event:String, listener:Function):Boolean
[static] Checks to see if a specified event listener exists.
Facebook
  
hasNext(data:Object):Boolean
[static] Asks if another page exists after this result object.
Facebook
  
hasPrevious(data:Object):Boolean
[static] Asks if a page exists before this result object.
Facebook
  
init(applicationId:String, callback:Function = null, options:Object = null, accessToken:String = null):void
[static] Initializes this Facebook singleton with your Application ID using OAuth 2.0.
Facebook
  
login(callback:Function, options:Object = null):void
[static] Shows the Facebook login window to the end user.
Facebook
  
logout(callback:Function):void
[static] Logs the user out of their current session.
Facebook
  
mobileLogin(redirectUri:String, display:String = touch, extendedPermissions:Array = null):void
[static] Re-directs the user to a mobile-friendly login form.
Facebook
  
mobileLogout(redirectUri:String):void
[static] Logs the user out after being logged in with mobileLogin().
Facebook
  
nextPage(data:Object, callback:Function):FacebookRequest
[static] Retrieves the next page that is associated with result object passed in.
Facebook
  
postData(method:String, callback:Function = null, params:Object = null):void
[static] Shortcut method to post data to Facebook.
Facebook
  
previousPage(data:Object, callback:Function):FacebookRequest
[static] Retrieves the previous page that is associated with result object passed in.
Facebook
  
removeJSEventListener(event:String, listener:Function):void
[static] Removes a Javascript event listener, added by Facebook.addJSEventListener();
Facebook
  
setCanvasAutoResize(autoSize:Boolean = true, interval:uint = 100):void
[static]
Facebook
  
setCanvasSize(width:Number, height:Number):void
[static]
Facebook
  
ui(method:String, data:Object, callback:Function = null, display:String = null):void
[static] Shows a Facebook sharing dialog.
Facebook
  
uploadVideo(method:String, callback:Function = null, params:* = null):void
[static] Shortcut method to upload video to Facebook.
Facebook
Property Detail
localeproperty
locale:String  [write-only]


Implementation
    public static function set locale(value:String):void
Constructor Detail
Facebook()Constructor
public function Facebook()

Creates an instance of Facebook.

Method Detail
addJSEventListener()method
public static function addJSEventListener(event:String, listener:Function):void

Utility method to add listeners to the underlying Facebook library.

Parameters

event:String — Name of the Javascript event to listen for.
 
listener:Function — Name of function to call when event is fired. This method will need to accept an optional result:Object, that will be the decoded JSON result, if one exists.

See also

api()method 
public static function api(method:String, callback:Function = null, params:* = null, requestMethod:String = 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: /me/friends
 
callback:Function (default = null) — 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:* (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:String (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
batchRequest()method 
public static function batchRequest(batch:Batch, callback:Function = null):void

Executes a batch api operation on facebook.

Parameters

batch:Batch — The batch to send to facebook.
 
callback:Function (default = null)

See also

com.facebook.graph.data.Batch
The callback to execute when this operation is complete.
callJS()method 
public static function callJS(methodName:String, params:Object):void

Calls an arbitrary Javascript method on the underlying HTML page.

Parameters

methodName:String
 
params:Object

callRestAPI()method 
public static function callRestAPI(methodName:String, callback:Function, values:* = null, requestMethod:String = 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 — Any values to pass to this request.
 
values:* (default = null) — URLRequestMethod used to send data to Facebook.
 
requestMethod:String (default = GET)

deleteObject()method 
public static function deleteObject(method:String, callback:Function = null):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 (default = null)

See also

http://developers.facebook.com/docs/api#deleting
com.facebook.graph.net.FacebookDesktop.api()
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()
getAuthResponse()method 
public static function getAuthResponse():FacebookAuthResponse

Synchronous method to retrieve the current user's auth response.

Returns
FacebookAuthResponse
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

getLoginStatus()method 
public static function getLoginStatus():void

Asynchronous method to get the user's current session from Facebook. This method calls out to the underlying Javascript SDK to check what the current user's login status is. You can listen for a javscript event by using Facebook.addJSEventListener('auth.sessionChange', callback)

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

hasJSEventListener()method 
public static function hasJSEventListener(event:String, listener:Function):Boolean

Checks to see if a specified event listener exists.

Parameters

event:String
 
listener:Function

Returns
Boolean
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, options:Object = null, accessToken:String = null):void

Initializes this Facebook singleton with your Application ID using OAuth 2.0. 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.
 
options:Object (default = null) — (Optional) Object of options used to instantiate the underling Javascript SDK
 
accessToken:String (default = null) — (Optional) A valid Facebook access token. If you have a previously saved access token, you can pass it in here.

See also

login()method 
public static function login(callback:Function, options:Object = null):void

Shows the Facebook login window to the end user.

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.
 
options:Object (default = null) — Values to modify the behavior of the login window. http://developers.facebook.com/docs/reference/javascript/FB.login

logout()method 
public static function logout(callback:Function):void

Logs the user out of their current session.

Parameters

callback:Function — Method to call when logout is complete.

mobileLogin()method 
public static function mobileLogin(redirectUri:String, display:String = touch, extendedPermissions:Array = null):void

Re-directs the user to a mobile-friendly login form.

Parameters

redirectUri:String — After a successful login, Facebook will redirect the user back to this URL, where the underlying Javascript SDK will notify this swf that a valid login has occurred.
 
display:String (default = touch) — Type of login form to show to the user.
  • touch Default; (Recommended) Smartphone, full featured web browsers.
  • wap; Older mobile web browsers, shows a slimmer UI to the end user.
 
extendedPermissions:Array (default = null) — (Optional) Array of extended permissions to ask the user for once they are logged in.

See also

mobileLogout()method 
public static function mobileLogout(redirectUri:String):void

Logs the user out after being logged in with mobileLogin().

Parameters

redirectUri:String — After logout, Facebook will redirect the user back to this URL.

nextPage()method 
public static function nextPage(data:Object, callback:Function):FacebookRequest

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.

Returns
FacebookRequest

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 = null, params:Object = null):void

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

Parameters

method:String
 
callback:Function (default = null)
 
params:Object (default = null)

See also

com.facebook.graph.net.Facebook.api()
previousPage()method 
public static function previousPage(data:Object, callback:Function):FacebookRequest

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.

Returns
FacebookRequest

See also

com.facebook.graph.net.FacebookDesktop.request()
http://developers.facebook.com/docs/api#reading
removeJSEventListener()method 
public static function removeJSEventListener(event:String, listener:Function):void

Removes a Javascript event listener, added by Facebook.addJSEventListener();

Parameters

event:String
 
listener:Function

See also

setCanvasAutoResize()method 
public static function setCanvasAutoResize(autoSize:Boolean = true, interval:uint = 100):void

Parameters

autoSize:Boolean (default = true)
 
interval:uint (default = 100)

See also

setCanvasSize()method 
public static function setCanvasSize(width:Number, height:Number):void

Parameters

width:Number
 
height:Number

See also

ui()method 
public static function ui(method:String, data:Object, callback:Function = null, display:String = null):void

Shows a Facebook sharing dialog.

Parameters

method:String — The related method for this dialog (ex. stream.publish).
 
data:Object — Data to pass to the dialog, date will be JSON encoded.
 
callback:Function (default = null) — (Optional) Method to call when complete
 
display:String (default = null) — (Optional) The type of dialog to show (iframe or popup).

See also

uploadVideo()method 
public static function uploadVideo(method:String, callback:Function = null, params:* = null):void

Shortcut method to upload video to Facebook.

Parameters

method:String — The method to call on the Graph API. For example, to upload a video, pass in /me/videos. To upload to an friend's wall, pass in /USER_ID/videos.
 
callback:Function (default = null) — 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:* (default = null) — An object containing the title, description, fileName (including extension), and video (FileReference or ByteArray)

See also