DISCONTINUATION OF PROJECT.
This project will no longer be maintained by Intel.
Intel has ceased development and contributions including, but not limited to, maintenance, bug fixes, new releases, or updates, to this project.
Intel no longer accepts patches to this project.
If you have an ongoing need to use this project, are interested in independently developing it, or would like to maintain patches for the open source software community, please create your own fork of this project. DISCONTINUATION OF PROJECT. This project will no longer be maintained by Intel. Intel will not provide or guarantee development of or support for this project, including but not limited to, maintenance, bug fixes, new releases or updates. Patches to this project are no longer accepted by Intel. In an effort to support the developer community, Intel has made this project available under the terms of the Apache License, Version 2. If you have an ongoing need to use this project, are interested in independently developing it, or would like to maintain patches for the community, please create your own fork of the project.
Integrate your application with Facebook.
This Intel XDK Cordova plugin and API has been deprecated. A suggested alternative Cordova plugin for use on Android and iOS platforms is available as a [third-party plugin](http://wizcorp.tumblr.com/post/91812168412/the-semi-official-facebook- phonegap-plugin-comes-to). Coverage for all platforms is available using [this JavaScript micro library](http://coenraets.org/blog/2014/04/facebook-phonegap-cordova-without- plugin/) (this is not a plugin). In addition, a general-purpose OAuth2 JavaScript library (no plugin required) named "HelloJS" can be used to log into Facebook (as well as a variety of other services).
This object gives applications the capability to log users into Facebook in order to access their Facebook Graph as well as to post to the news feed and share request dialogs.
For more information on on how to use the Facebook JavaScript API commands in a native application, stop by this Facebook Integration article.
- enableFrictionlessRequests — This command ensures that news feed requests are "frictionless" in that it enables users to send requests to specific friends without having to click on a pop-up confirmation dialog
- login — This method logs the user into Facebook
- logout — This method logs the user out of Facebook
- requestWithGraphAPI — This method makes calls to the new Graph Facebook API
- requestWithRestAPI — This method makes calls to the older REST Facebook API
- showAppRequestDialog — This method displays the Facebook application request dialog
- showNewsFeedDialog — This method displays the Facebook news feed submission dialog
- intel.xdk.facebook.busy — Fired if a second Facebook request is made while a previous request is still pending
- intel.xdk.facebook.dialog.complete — This event is fired in response to a news feed or app request dialog
- intel.xdk.facebook.dialog.fail — This event is fired if Facebook tries to log the user on during a dialog request, but the login fails
- intel.xdk.facebook.login — Fired after logging a user into Facebook
- intel.xdk.facebook.logout — Fired after logging a user out of Facebook
- intel.xdk.facebook.request.response — Fired in response to a Facebook API request
- intel.xdk.facebook.session.invalidate — Fired if the Facebook session is invalidated
This command ensures that news feed requests are "frictionless" in that it enables users to send requests to specific friends without having to click on a pop-up confirmation dialog
intel.xdk.facebook.enableFrictionlessRequests();This command ensures that news feed requests are "frictionless" in that it enables users to send requests to specific friends without having to click on a pop-up confirmation dialog. This command option is for iOS only since Android requests are automatically set to be "frictionless".
- Apple iOS
- Google Android
This method logs the user into Facebook
intel.xdk.facebook.login(permissions);This command is used to log the user into Facebook. When it is run, a dialog generated by Facebook should appear allowing the user to enter their credentials. Depending on the result of that interaction with Facebook, the application will receive a JavaScript event (intel.xdk.facebook.login) indicating whether the login was successful or not. This method will log the user in with a series of default permissions if no permissions parameter is specified.
- Apple iOS
- Google Android
- intel.xdk.facebook.login: This event is fired upon completion of the interaction with Facebook and will indicate either successful login or failure.
alert("about to log into facebook");
document.addEventListener("intel.xdk.facebook.login",function(e){
if (e.success == true)
{ console.log("Facebook Log in Successful"); }
else
{ console.log("Unsuccessful Login"); }
},false);
intel.xdk.facebook.login("publish_stream,publish_actions,offline_access");This method logs the user out of Facebook
intel.xdk.facebook.logout();- Apple iOS
- Google Android
- intel.xdk.facebook.logout: This event is fired upon completion of Facebook logout
alert("logging out of facebook");
document.addEventListener("intel.xdk.facebook.logout",function(e){
if (e.success == true)
{ console.log("Logged out of Facebook"); }
else
{ console.log("Unsuccessful Logout"); }
},false);
intel.xdk.facebook.logout();This method makes calls to the new Graph Facebook API
intel.xdk.facebook.requestWithGraphAPI(path, method, parameters);This method is used to make a request from the newer Facebook Graph API. For more information on this particular API, see Facebook’s documentation here.
- Apple iOS
- Google Android
- path: The Facebook Graph PATH to execute
- method: The request method to call the Facebook Graph API, typically GET or POST
- parameters: Any parameters required for the request
- intel.xdk.facebook.request.response: This event is fired upon completion of a Facebook API request.
var facebookUserID = "me"; //me = the user currently logged into Facebook
document.addEventListener("intel.xdk.facebook.request.response",function(e) {
console.log("Facebook User Friends Data Returned");
if (e.success == true) {
var data = e.data.data;
var outHTML = "";
for (var r=0; r< data.length; r++) {
outHTML += "<img src='http://graph.facebook.com/" + data[r]["id"] +
"/picture' info='" + data[r]["name"] + "' />";
}
document.getElementsByTagName("body")[0].innerHTML = outHTML;
document.removeEventListener("intel.xdk.facebook.request.response");
}
},false);
intel.xdk.facebook.requestWithGraphAPI(facebookUserID + "/friends","GET","");This method makes calls to the older REST Facebook API
intel.xdk.facebook.requestWithRestAPI(command, method, parameters);This method is used to make a request using the older Facebook REST API. This API is being deprecated by Facebook, and may not be available in the future. For more information on Facebook’s REST API see the Facebook documentation here.
- Apple iOS
- Google Android
- command: The REST API command to have Facebook execute
- method: The request method to call the Facebook REST API, typically GET or POST
- parameters: Any parameters required for the request
- intel.xdk.facebook.request.response: This event is fired upon completion of a Facebook API request.
This method displays the Facebook application request dialog
intel.xdk.facebook.showAppRequestDialog(parameters);The Request Dialog sends a Request from one user (the sender) to one or more users (the recipients). The Request Dialog can be used to send a Request directly from one user to another or display a Multi Friend Selector Dialog, allowing the sending user to select multiple recipient users.
- Apple iOS
- Google Android
- parameters: A JSON object holding the appropriate parameters for the request as specified in Facebook's documentation
- intel.xdk.facebook.dialog.complete: This event is fired upon completion of the dialog request.
- intel.xdk.facebook.dialog.fail: This event is fired if Facebook attempted to log the user in during a dialog request, but the login failed.
document.addEventListener("intel.xdk.facebook.dialog.complete",function(e) {
console.log("Permissions Request Returned");
if (e.success == true) {
console.log("News feed updated successfully");
} else { console.log("permissions request failed"); }
},false);
var objParameters = {"to":"USER_ID_HERE","message":"My Awesome
Message","title":"A title for this dialog would go here"}
intel.xdk.facebook.showAppRequestDialog(objParameters);This method displays the Facebook news feed submission dialog
intel.xdk.facebook.showNewsFeedDialog(parameters);- Apple iOS
- Google Android
- intel.xdk.facebook.dialog.complete: This event is fired upon completion of the dialog request.
- intel.xdk.facebook.dialog.fail: This event is fired if Facebook attempted to log the user in during a dialog request, but the login failed.
//This allows the application to post to Facebook for the logged in user
document.addEventListener("intel.xdk.facebook.dialog.complete",function(e) {
console.log("News Feed Event Returned");
if (e.success == true) {
console.log("News feed updated successfully");
}
},false);
var objParameters = {
"picture":"http://fbrell.com/f8.jpg",
"name":"Facebook Dialog",
"caption":"This is my caption",
"description":"Using Dialogs to interact with users.",
"link":"http://xdk.intel.com"
}
intel.xdk.facebook.showNewsFeedDialog(objParameters);Fired if a second Facebook request is made while a previous request is still pending
This event is fired in response to a news feed or app request dialog
Returns an event object with the properties success and data
This event is fired if Facebook tries to log the user on during a dialog request, but the login fails
Fired after logging a user into Facebook
Returns an event object with the properties success and data
Fired after logging a user out of Facebook
Returns an event object with the properties success and data
Fired in response to a Facebook API request
Returns an event object with the properties success and data
Fired if the Facebook session is invalidated