Official docs:
Testing
- open_in_new JavaScript Test Console — run SDK snippets.
- open_in_new Graph API Explorer — call the Graph API interactively.
Loading the JavaScript SDK
<script>
window.fbAsyncInit = function() {
FB.init({
appId : 'your-app-id',
xfbml : true,
version : 'v3.2'
});
};
</script>
<script async defer src="https://connect.facebook.net/en_US/sdk.js"></script>
appId is the application ID from the open_in_new App Dashboard
.
If you prefer to keep the loader in one place (including the async script injection):
<script>
window.fbAsyncInit = function() {
FB.init({
appId : '{your-app-id}',
cookie : true,
xfbml : true,
version : '{api-version}'
});
FB.AppEvents.logPageView();
};
(function(d, s, id){
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {return;}
js = d.createElement(s); js.id = id;
js.src = "https://connect.facebook.net/en_US/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
</script>
Language for social plugins
Change the locale in the SDK URL, for example:
<script async defer src="https://connect.facebook.net/es_LA/sdk.js"></script>
Setup checklist
- Create an App ID.
- Enable the Facebook Login product for the app.
- Use the Facebook Login Quickstart to fill in the required parameters quickly.
Andrew Dorokhov