The Facebook API login "quickstart" page says to put the following code in your page:
<script>
window.fbAsyncInit = function() {
FB.init({
appId : '{your-app-id}',
cookie : true,
xfbml : true,
version : '{latest-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 = "//connect.facebook.net/en_US/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
</script>
App ID is easy, but what on earth is it expecting for {latest-api-version}
? I've tried both '2.1'
and '2'
and both values throw "invalid version specified" to the console.
The trick is including v
in the version. Some users may also have neglected to remove the {brackets}.
As of 2021-06-08 the code should look like this:
version : 'v11.0'
Readers from the future (or the past) can view this table for different versions: https://developers.facebook.com/docs/graph-api/changelog/versions
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With