Functions for interacting with Facebook APIs.
Static methods
staticaccess_token():Null<String>
Get the current Facebook access token.
This function returns the currently stored access token after a previous sucessful login. If it returns null no access token exists and you need to perform a login to get the wanted permissions.
Returns:
the access token or null if the user is not logged in
staticdisable_event_usage():Void
Disable event usage with Facebook Analytics.
This function will disable event usage for Facebook Analytics which means that Facebook won't be able to use event data for ad-tracking. Events will still be sent to Facebook for insights.
NOTE! Event usage cannot be controlled and is always enabled for the Facebook Canvas platform, therefore this function has no effect on Facebook Canvas.
staticenable_event_usage():Void
Enable event usage with Facebook Analytics.
This function will enable event usage for Facebook Analytics which means that Facebook will be able to use event data for ad-tracking.
NOTE! Event usage cannot be controlled and is always enabled for the Facebook Canvas platform, therefore this function has no effect on Facebook Canvas.
staticlogin_with_publish_permissions<T>(permissions:Table<Int, String>, audience:FacebookAudience, callback:(T, FacebookLoginData) ‑> Void):Void
Login to Facebook and request a set of publish permissions. The user is prompted to authorize the application using the login dialog of the specific platform. Even if the user is already logged in to Facebook this function can still be used to request additional publish permissions.
NOTE that this function cannot be used to request read permissions.
If the application requires both publish and read permissions, individual
calls to both login_with_publish_permissions
and login_with_read_permissions
has to be made.
A comprehensive list of permissions can be found in the Facebook documentation, as well as a guide to best practises for login management.
Parameters:
permissions | Table with the requested publish permission strings. |
---|---|
audience | The audience that should be able to see the publications. |
callback | Callback function that takes the arguments (self, data), the callback is executed when the permission request dialog is closed. |
staticlogin_with_read_permissions<T>(permissions:Table<Int, String>, callback:(T, FacebookLoginData) ‑> Void):Void
Login to Facebook and request a set of read permissions. The user is prompted to authorize the application using the login dialog of the specific platform. Even if the user is already logged in to Facebook this function can still be used to request additional read permissions.
NOTE that this function cannot be used to request publish permissions. If the application requires both read and publish permissions, individual calls to both login_with_read_permissions and login_with_publish_permissions has to be made.
A comprehensive list of permissions can be found in the Facebook documentation, as well as a guide to best practises for login management.
Parameters:
permissions | Table with the requested read permission strings. |
---|---|
callback | (function) Callback function that takes the arguments (self, data), the callback is executed when the permission request dialog is closed. |
staticpermissions():Table<Int, String>
Get the currently granted permissions.
This function returns a table with all the currently granted permission strings.
Returns:
the permissions
staticpost_event(event:EitherType<String, FacebookEvent>, value_to_sum:Int, ?params:Table<EitherType<FacebookParam, String>, Dynamic>):Void
Post an event to Facebook Analytics.
This function will post an event to Facebook Analytics where it can be used in the Facebook Insights system.
Parameters:
event | An event can either be one of the predefined constants or a text which can be used to define a custom event that is registered with Facebook Analytics. |
---|---|
value_to_sum | A numeric value for the event. This should represent the value of the event, such as the level achieved, price for an item or number of orcs killed. |
params | A table with parameters and their values. A key in the table can either be one of the predefined constants below or a text which can be used to define a custom parameter. Optional argument. |
staticshow_dialog<T, TParam, TResult>(dialog:FacebookDialogType<TParam, TResult>, param:TParam, callback:(T, TResult, Bool) ‑> Void):Void
Show facebook web dialog.
Display a Facebook web dialog of the type specified in the dialog
parameter.
The param
table should be set up according to the requirements of each dialog
type. Note that some parameters are mandatory. Below is the list of available dialogs and
where to find Facebook's developer documentation on parameters and response data.
Parameters:
dialog | dialog to show. "apprequests", "feed" or "appinvite" |
---|---|
param | table with dialog parameters |
callback | callback function with parameters (self, result, error) that is called when the dialog is closed. |