Facebook Class
This class provides access to Facebook Connect. It class allows a user to login, logout, post messages, pictures, retrieves status, friends etc.
Item Index
Methods
this
appId
permissions
Parameters:
-
appId
String= "" The Facebook application identifier.
-
permissions
Array= null The list of strings of required permissions.
Example:
var facebook = new Facebook("", ["offline_access", "status_update", "read_stream", "publish_stream"]);
var facebook = new Facebook("288852541221599", ["offline_access", "status_update", "read_stream", "publish_stream"]);
dialog
url
params
Displays a Facebook UI dialog for publishing posts to a user's stream. This is very easy way to post any data to user's wall.
Parameters:
-
url
StringURL to be used in Dialog.
-
params
Object= null The parameters in JSON object to be sent to Dialog.
Example:
facebook.dialog("feed", {caption: "Moscrif Test.", link: "https://moscrif.com", picture: "https://moscrif.com/images/logo.png", actions: {name: "Moscrif Test", link: "https://moscrif.com"}, description: "Moscrif test."});
isAvailable
() static
Returns true when Facebook Connect is supported, otherwise false.
login
()
Prompts the user to login to Facebook.
logout
()
Logs out user from Facebook Connect.
request
path
method
params
Get or post data to the logged in Facebook account.
Parameters:
-
path
StringThe Graph API endpoint.
-
method
Symbol= #get The HTTP method, can be #get or #post.
-
params
Object= null The parameters in JSON object to be sent to Facebook. For more information visit .
Example:
facebook.request("me");
facebook.request("me/friends", #get);
facebook.request("me/picture", #get, {redirect: false, type: "large"});
facebook.request("me/feed", #post, {title: "Moscrif Test", type: "status", message: "Moscrif Test.", description: "Moscrif test."});
facebook.request("me/feed", #post, {title: "Moscrif Test", type: "link", link: "https://moscrif.com", picture: "https://moscrif.com/images/logo.png", description: "Moscrif test."});
var bitmap = Bitmap.fromFile("app://foto.jpg");
facebook.request("me/photos", #post, {title: "Moscrif Test", source: bitmap, message: "Moscrif Test.", description: "Moscrif test."});
Events
onDialog
Called when dialog has been returned successfully.
Event Payload:
-
url
StringThe response in url format.
Example:
facebook.onDialog = function(url)
{
logI("onDialog : ", url.debugShow());
}
onDialogFailed
Called when dialog has been failed.
Event Payload:
-
error
StringReason of failure.
Example:
facebook.onDialogFailed = function(error)
{
logI("onDialogFailed : ", error.debugShow());
}
onLogin
Called when the user has been successfully logged in.
onLoginFailed
Event Payload:
-
error
StringReason of failure.
onLogout
Called when the user has been successfully logged out.
onRequest
Called when request has been returned successfully.
Event Payload:
-
data
ObjectThe response in JSON format.
Example:
facebook.onRequest = function(data)
{
logI("onRequest : ", data.debugShow());
}