Prepare all stuffs for using Facebook JavaScript SDK
- Append "fb-root" element (if not exists)
- Append Facebook JavaScript SDK resource (if not exists)
on()
let you attach callback for "ready", "login" eventrender()
will parse XFBML (ex: Like Button) without asynchronous context
Firstly, get your application id on https://developers.facebook.com/, then initialize FBReady with the appId.
var fbready = new FBReady( your_application_id );
You don't need to install "fb-root" or script code to import SDK.
Attach callback for "ready" event. This will be called when anything about connection is done.
fbready.on("ready", function(){
console.log("Connected to Facebook !");
});
To do something with authenticated context, "login" event is usable.
fbready.on("login", function(){
console.log("Logged in !");
FB.api(...);
});
FBReady doesn't have any interface to login.
Call FB.login()
on your own context.
Use render
to show XFBML widget such as "Like Button".
fbready.render();
No need to call it in callback.
render()
just registers callback and waits for preparing application.
-
If
FB
object exists, FBReady try to use theFB
and doesn't install new "all.js". -
If
FB.init()
has been already called, that looks like working but not good.
You will see a message like "FB.init has already been called".
It may be caused by installing code for widgets such as "Like Button"
because they call automaticallyFB.init
. -
In context of callback for
FB.getLoginStatus()
, FBReady does not work.
- ready : Connection process is done
- login : Logged in
Register callback for the named event.
Fire the named event.
Render facebook widgets on the page.
This call FB.XFBML.parse()
mach3