Packagecom.facebook.graph
Classpublic class FacebookMobile
InheritanceFacebookMobile Inheritance AbstractFacebook Inheritance Object

For use in Mobile, to access the Facebook Graph API from the Mobile phone.



Public Properties
 PropertyDefined By
  locale : String
[static] [write-only]
FacebookMobile
  manageSession : Boolean
[static] Setting to true (default), this class will manage the session and access token internally.
FacebookMobile
Protected Properties
 PropertyDefined By
  applicationId : String
FacebookMobile
  _canInit : Boolean = false
[static]
FacebookMobile
  initCallback : Function
FacebookMobile
  _instance : FacebookMobile
[static]
FacebookMobile
  loginCallback : Function
FacebookMobile
  loginWindow : MobileLoginWindow
FacebookMobile
  logoutCallback : Function
FacebookMobile
  _manageSession : Boolean = true
FacebookMobile
  stageRef : Stage
FacebookMobile
  webView : StageWebView
FacebookMobile
Public Methods
 MethodDefined By
  
Creates a new FacebookMobile instance
FacebookMobile
  
api(method:String, callback:Function, params:* = null, requestMethod:String = GET):void
[static] Makes a new request on the Facebook Graph API.
FacebookMobile
  
batchRequest(batch:Batch, callback:Function = null):void
[static] Executes a batch api operation on facebook.
FacebookMobile
  
callRestAPI(methodName:String, callback:Function = null, values:* = null, requestMethod:String = GET):void
[static] Used to make old style RESTful API calls on Facebook.
FacebookMobile
  
deleteObject(method:String, callback:Function):void
[static] Deletes an object from Facebook.
FacebookMobile
  
fqlMultiQuery(queries:FQLMultiQuery, callback:Function = null, parser:IResultParser = null):void
[static] Executes an FQL multiquery on api.facebook.com.
FacebookMobile
  
fqlQuery(query:String, callback:Function = null, values:Object = null):void
[static] Executes an FQL query on api.facebook.com.
FacebookMobile
  
getImageUrl(id:String, type:String = null):String
[static] Utility method to format a picture URL, in order to load an image from Facebook.
FacebookMobile
  
getRawResult(data:Object):Object
[static] Returns a reference to the entire raw object Facebook returns (including paging, etc.).
FacebookMobile
  
[static] Synchronous call to return the current user's session.
FacebookMobile
  
hasNext(data:Object):Boolean
[static] Asks if another page exists after this result object.
FacebookMobile
  
hasPrevious(data:Object):Boolean
[static] Asks if a page exists before this result object.
FacebookMobile
  
init(applicationId:String, callback:Function, accessToken:String = null):void
[static] Initializes this Facebook singleton with your application ID.
FacebookMobile
  
login(callback:Function, stageRef:Stage, extendedPermissions:Array, webView:StageWebView = null, display:String = touch):void
[static] Opens a new login window so the current user can log in to Facebook.
FacebookMobile
  
logout(callBack:Function = null, appOrigin:String = null):void
[static] Clears a user's local session.
FacebookMobile
  
nextPage(data:Object, callback:Function):FacebookRequest
[static] Retrieves the next page that is associated with result object passed in.
FacebookMobile
  
postData(method:String, callback:Function, params:* = null):void
[static] Shortcut method to post data to Facebook.
FacebookMobile
  
previousPage(data:Object, callback:Function):FacebookRequest
[static] Retrieves the previous page that is associated with result object passed in.
FacebookMobile
  
requestExtendedPermissions(callback:Function, webView:StageWebView, ... extendedPermissions):void
[static] Opens a new window that asks the current user for extended permissions.
FacebookMobile
  
uploadVideo(method:String, callback:Function = null, params:* = null):void
[static] Shortcut method to upload video to Facebook.
FacebookMobile
Protected Methods
 MethodDefined By
  
init(applicationId:String, callback:Function, accessToken:String = null):void
FacebookMobile
Protected Constants
 ConstantDefined By
  SO_NAME : String = com.facebook.graph.FacebookMobile
[static]
FacebookMobile
Property Detail
_canInitproperty
protected static var _canInit:Boolean = false

_instanceproperty 
protected static var _instance:FacebookMobile

_manageSessionproperty 
protected var _manageSession:Boolean = true

applicationIdproperty 
protected var applicationId:String

initCallbackproperty 
protected var initCallback:Function

localeproperty 
locale:String  [write-only]


Implementation
    public static function set locale(value:String):void
loginCallbackproperty 
protected var loginCallback:Function

loginWindowproperty 
protected var loginWindow:MobileLoginWindow

logoutCallbackproperty 
protected var logoutCallback:Function

manageSessionproperty 
public static var manageSession:Boolean

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.

stageRefproperty 
protected var stageRef:Stage

webViewproperty 
protected var webView:StageWebView

Constructor Detail
FacebookMobile()Constructor
public function FacebookMobile()

Creates a new FacebookMobile instance

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

See also

com.facebook.graph.net.FacebookMobile.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.FacebookMobile.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
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 
protected function init(applicationId:String, callback:Function, accessToken:String = null):void

Parameters

applicationId:String
 
callback:Function
 
accessToken:String (default = null)

init()method 
public static function init(applicationId:String, callback:Function, 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 — 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) — If you have a previously saved access_token, you can pass it in here.

login()method 
public static function login(callback:Function, stageRef:Stage, extendedPermissions:Array, webView:StageWebView = null, display:String = touch):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.
 
stageRef:Stage — A reference to the stage
 
extendedPermissions:Array — (Optional) Array of extended permissions to ask the user for once they are logged in.
 
webView:StageWebView (default = null) — (Optional) The instance of StageWebView to use for the login window
 
display:String (default = touch) — (Optional) The display type for the OAuth dialog. "wap" for older mobile browsers, "touch" for smartphones. The Default is "touch". 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):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, params:* = null):void

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

Parameters

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

See also

com.facebook.graph.net.FacebookMobile.request()
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
requestExtendedPermissions()method 
public static function requestExtendedPermissions(callback:Function, webView:StageWebView, ... 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.
 
webView:StageWebView — The instance of StageWebView to use.
 
... extendedPermissions — Array of extended permissions to ask the user for once they are logged in.

See also

com.facebook.graph.net.FacebookMobile.login()
http://developers.facebook.com/docs/authentication/permissions
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

Constant Detail
SO_NAMEConstant
protected static const SO_NAME:String = com.facebook.graph.FacebookMobile