Version: stable
FUNCTION | |
---|---|
login_with_permissions() | |
logout() | |
access_token() | |
permissions() | |
post_event() | |
enable_event_usage() | |
disable_event_usage() | |
show_dialog() | |
get_version() | |
deferred_deep_link() |
login_with_permissions(permissions,audience,callback)
PARAMETERS
permissions |
table with the requested publish permission strings. |
audience |
The audience that should be able to see the publications. Can be any of - `facebook.AUDIENCE_NONE` - `facebook.AUDIENCE_ONLYME` - `facebook.AUDIENCE_FRIENDS` - `facebook.AUDIENCE_EVERYONE` |
callback |
Callback function that is executed when the permission request dialog is closed. |
EXAMPLES
Log in to Facebook with a set of publish permissions
local permissions = {"publish_actions"} facebook.login_with_permissions(permissions, facebook.AUDIENCE_FRIENDS, function(self, data) if (data.status == facebook.STATE_OPEN and data.error == nil) then print("Successfully logged into Facebook") pprint(facebook.permissions()) else print("Failed to get permissions (" .. data.status .. ")") pprint(data) end end)
Log in to Facebook with a set of read permissions
local permissions = {"public_profile", "email", "user_friends"} facebook.login_with_read_permissions(permissions, facebook.AUDIENCE_EVERYONE, function(self, data) if (data.status == facebook.STATE_OPEN and data.error == nil) then print("Successfully logged into Facebook") pprint(facebook.permissions()) else print("Failed to get permissions (" .. data.status .. ")") pprint(data) end end)
logout()
PARAMETERS
access_token()
PARAMETERS
RETURNS
string |
the access token or nil if the user is not logged in |
EXAMPLES
Get the current access token, then use it to perform a graph API request.
local function get_name_callback(self, id, response) -- do something with the response end function init(self) -- assuming we are already logged in. local token = facebook.access_token() if token then local url = "https://graph.facebook.com/me/?access_token=".. token http.request(url, "GET", get_name_callback) end end
permissions()
PARAMETERS
RETURNS
table |
The permissions |
EXAMPLES
Check the currently granted permissions for a particular permission
for _,permission in ipairs(facebook.permissions()) do if permission == "user_likes" then -- "user_likes" granted... break end end
post_event(event,value,params)
PARAMETERS
event |
An event can either be one of the predefined constants below or a text string which can be used to define a custom event that is registered with Facebook Analytics. - `facebook.EVENT_ACHIEVED_LEVEL` - `facebook.EVENT_ADDED_PAYMENT_INFO` - `facebook.EVENT_ADDED_TO_CART` - `facebook.EVENT_ADDED_TO_WISHLIST` - `facebook.EVENT_COMPLETED_REGISTRATION` - `facebook.EVENT_COMPLETED_TUTORIAL` - `facebook.EVENT_INITIATED_CHECKOUT` - `facebook.EVENT_PURCHASED` - `facebook.EVENT_RATED` - `facebook.EVENT_SEARCHED` - `facebook.EVENT_SPENT_CREDITS` - `facebook.EVENT_TIME_BETWEEN_SESSIONS` - `facebook.EVENT_UNLOCKED_ACHIEVEMENT` - `facebook.EVENT_VIEWED_CONTENT` |
value |
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 |
Optional 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. - `facebook.PARAM_CONTENT_ID` - `facebook.PARAM_CONTENT_TYPE` - `facebook.PARAM_CURRENCY` - `facebook.PARAM_DESCRIPTION` - `facebook.PARAM_LEVEL` - `facebook.PARAM_MAX_RATING_VALUE` - `facebook.PARAM_NUM_ITEMS` - `facebook.PARAM_PAYMENT_INFO_AVAILABLE` - `facebook.PARAM_REGISTRATION_METHOD` - `facebook.PARAM_SEARCH_STRING` - `facebook.PARAM_SOURCE_APPLICATION` - `facebook.PARAM_SUCCESS` |
EXAMPLES
Post a spent credits event to Facebook Analytics
params = {[facebook.PARAM_LEVEL] = 30, [facebook.PARAM_NUM_ITEMS] = 2} facebook.post_event(facebook.EVENT_SPENT_CREDITS, 25, params)
enable_event_usage()
PARAMETERS
disable_event_usage()
PARAMETERS
show_dialog(dialog,param,callback)
PARAMETERS
dialog |
Dialog to show - `"apprequests"` - `"feed"` - `"appinvite"` |
param |
table with dialog parameters |
callback |
Callback function that is called when the dialog is closed. |
EXAMPLES
Show a dialog allowing the user to share a post to their timeline
local function fb_share(self, result, error) if error then -- something did not go right... else -- do something sensible end end function init(self) -- assuming we have logged in with publish permissions local param = { link = "http://www.mygame.com",picture="http://www.mygame.com/image.jpg" } facebook.show_dialog("feed", param, fb_share) end
get_version()
PARAMETERS
RETURNS
string |
The Facebook SDK version |
deferred_deep_link(callback)
PARAMETERS
callback |
Callback function that is called when information is ready. |
EXAMPLES
Show a dialog allowing the user to share a post to their timeline
local function deferred_deep_link_callback(self, result, error) if error then print(error.error) else pprint(result) end end function init(self) facebook.deferred_deep_link(deferred_deep_link_callback) end
The Facebook login session is open
The Facebook login session has closed because login failed
Game request action type "none" for "apprequests" dialog
Game request action type "send" for "apprequests" dialog
Game request action type "askfor" for "apprequests" dialog
Game request action type "turn" for "apprequests" dialog
Game request filter type "none" for "apprequests" dialog
Game request filter type "app_users" for "apprequests" dialog
Game request filter type "app_non_users" for "apprequests" dialog
Log this event when the user has achieved a level
Log this event when the user has entered their payment info
Log this event when the user has added an item to their cart The value_to_sum passed to facebook.post_event should be the item's price.
Log this event when the user has added an item to their wish list The value_to_sum passed to facebook.post_event should be the item's price.
Log this event when a user has completed registration with the app
Log this event when the user has completed a tutorial in the app
Log this event when the user has entered the checkout process The value_to_sum passed to facebook.post_event should be the total price in the cart.
Log this event when the user has completed a purchase. The value_to_sum passed to facebook.post_event should be the numeric rating.
Log this event when the user has rated an item in the app
Log this event when a user has performed a search within the app
Log this event when the user has spent app credits The value_to_sum passed to facebook.post_event should be the number of credits spent.
Log this event when measuring the time between user sessions
Log this event when the user has unlocked an achievement in the app
Log this event when a user has viewed a form of content in the app
Parameter key used to specify an ID for the content being logged about The parameter key could be an EAN, article identifier, etc., depending on the nature of the app.
Parameter key used to specify a generic content type/family for the logged event The key is an arbitrary type/family (e.g. "music", "photo", "video") depending on the nature of the app.
Parameter key used to specify currency used with logged event Use a currency value key, e.g. "USD", "EUR", "GBP" etc. See See ISO-4217 for specific values.
Parameter key used to specify a description appropriate to the event being logged Use this for app specific event description, for instance the name of the achievement unlocked in the facebook.EVENT_UNLOCKED_ACHIEVEMENT event.
Parameter key used to specify the level achieved
Parameter key used to specify the maximum rating available Set to specify the max rating available for the facebook.EVENT_RATED event. E.g., "5" or "10".
Parameter key used to specify how many items are being processed Set to specify the number of items being processed for an facebook.EVENT_INITIATED_CHECKOUT or facebook.EVENT_PURCHASED event.
Parameter key used to specify whether payment info is available Set to specify if payment info is available for the facebook.EVENT_INITIATED_CHECKOUT event.
Parameter key used to specify method user has used to register for the app Set to specify what registation method a user used for the app, e.g. "Facebook", "email", "Twitter", etc.
Parameter key used to specify user search string Set this to the the string that the user provided for a search operation.
Parameter key used to specify source application package
Parameter key used to specify activity success Set this key to indicate whether the activity being logged about was successful or not.
Publish permission to reach no audience
Publish permission to reach only me (private to current user)
Publish permission to reach user friends
Publish permission to reach everyone